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/database.rs | |
| 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/database.rs')
| -rw-r--r-- | crates/atuin-client/src/database.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/atuin-client/src/database.rs b/crates/atuin-client/src/database.rs index 5bdbb75c..b64ff4ce 100644 --- a/crates/atuin-client/src/database.rs +++ b/crates/atuin-client/src/database.rs @@ -130,8 +130,12 @@ impl Sqlite { let path = path.as_ref(); 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)?; } @@ -150,7 +154,6 @@ impl Sqlite { .await?; Self::setup_db(&pool).await?; - Ok(Self { pool }) } |
