diff options
| author | James Trew <66286082+jamestrew@users.noreply.github.com> | 2025-03-09 18:34:49 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-09 22:34:49 +0000 |
| commit | c05b8f6879bad7fa9a49094b15a39a45a0b458d6 (patch) | |
| tree | 57dcac9d789ed010d774030b439198f35c7f1367 /crates/atuin-client/src/record | |
| parent | feat: make new arrow key behavior configurable (#2606) (diff) | |
| download | atuin-c05b8f6879bad7fa9a49094b15a39a45a0b458d6.zip | |
fix: improve broken symlink error handling (#2589)
Check atuin setting paths (eg. `db_path`) for broken symlinks on
initialization and disable all shell hooks + print error message.
sqlite doesn't create db files even with `.create_if_missing` when the
db files are a broken symlink. This would cause sqlite to error and
atuin to panic on every single keypress.
Also improves related error handling when calling atuin client commands
directly.
Diffstat (limited to 'crates/atuin-client/src/record')
| -rw-r--r-- | crates/atuin-client/src/record/sqlite_store.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/atuin-client/src/record/sqlite_store.rs b/crates/atuin-client/src/record/sqlite_store.rs index 2937dbd7..c42476d4 100644 --- a/crates/atuin-client/src/record/sqlite_store.rs +++ b/crates/atuin-client/src/record/sqlite_store.rs @@ -17,6 +17,7 @@ use sqlx::{ use atuin_common::record::{ EncryptedData, Host, HostId, Record, RecordId, RecordIdx, RecordStatus, }; +use atuin_common::utils; use uuid::Uuid; use super::encryption::PASETO_V4; @@ -33,8 +34,12 @@ impl SqliteStore { debug!("opening sqlite database at {:?}", path); - let create = !path.exists(); - if create { + if utils::broken_symlink(path) { + eprintln!("Atuin: Sqlite db path ({path:?}) is a broken symlink. Unable to read or create replacement."); + std::process::exit(1); + } + + if !path.exists() { if let Some(dir) = path.parent() { fs::create_dir_all(dir)?; } |
