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/record/sqlite_store.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'crates/atuin-client/src/record') 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)?; } -- cgit v1.3.1