From c05b8f6879bad7fa9a49094b15a39a45a0b458d6 Mon Sep 17 00:00:00 2001 From: James Trew <66286082+jamestrew@users.noreply.github.com> Date: Sun, 9 Mar 2025 18:34:49 -0400 Subject: 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. --- crates/atuin-client/src/database.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'crates/atuin-client/src/database.rs') 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 }) } -- cgit v1.3.1