aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-client/src/settings.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/atuin-client/src/settings.rs')
-rw-r--r--crates/atuin-client/src/settings.rs32
1 files changed, 21 insertions, 11 deletions
diff --git a/crates/atuin-client/src/settings.rs b/crates/atuin-client/src/settings.rs
index c01281c7..a1b0724f 100644
--- a/crates/atuin-client/src/settings.rs
+++ b/crates/atuin-client/src/settings.rs
@@ -3,6 +3,7 @@ use std::{
};
use atuin_common::record::HostId;
+use atuin_common::utils;
use clap::ValueEnum;
use config::{
builder::DefaultState, Config, ConfigBuilder, Environment, File as ConfigFile, FileFormat,
@@ -852,24 +853,33 @@ impl Settings {
.map_err(|e| eyre!("failed to deserialize: {}", e))?;
// all paths should be expanded
- let db_path = settings.db_path;
- let db_path = shellexpand::full(&db_path)?;
- settings.db_path = db_path.to_string();
-
- let key_path = settings.key_path;
- let key_path = shellexpand::full(&key_path)?;
- settings.key_path = key_path.to_string();
-
- let session_path = settings.session_path;
- let session_path = shellexpand::full(&session_path)?;
- settings.session_path = session_path.to_string();
+ settings.db_path = Self::expand_path(settings.db_path)?;
+ settings.record_store_path = Self::expand_path(settings.record_store_path)?;
+ settings.key_path = Self::expand_path(settings.key_path)?;
+ settings.session_path = Self::expand_path(settings.session_path)?;
Ok(settings)
}
+ fn expand_path(path: String) -> Result<String> {
+ shellexpand::full(&path)
+ .map(|p| p.to_string())
+ .map_err(|e| eyre!("failed to expand path: {}", e))
+ }
+
pub fn example_config() -> &'static str {
EXAMPLE_CONFIG
}
+
+ pub fn paths_ok(&self) -> bool {
+ let paths = [
+ &self.db_path,
+ &self.record_store_path,
+ &self.key_path,
+ &self.session_path,
+ ];
+ paths.iter().all(|p| !utils::broken_symlink(p))
+ }
}
impl Default for Settings {