From 6ee7c089e01acdd62ff92801ebcaa474e6bead56 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Fri, 13 May 2022 03:32:28 +0200 Subject: [PATCH] Don't create config dir for server in default location if not needed ...respect ATUIN_CONFIG_DIR. The current behaviour is problematic when running atuin server as a system service with config dir in /etc/atuin. --- atuin-server/src/settings.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/atuin-server/src/settings.rs b/atuin-server/src/settings.rs index 8e8961e9c83..e67451735f3 100644 --- a/atuin-server/src/settings.rs +++ b/atuin-server/src/settings.rs @@ -17,15 +17,11 @@ pub struct Settings { impl Settings { pub fn new() -> Result { - let config_dir = atuin_common::utils::config_dir(); - let config_dir = config_dir.as_path(); - - create_dir_all(config_dir)?; - let mut config_file = if let Ok(p) = std::env::var("ATUIN_CONFIG_DIR") { PathBuf::from(p) } else { let mut config_file = PathBuf::new(); + let config_dir = atuin_common::utils::config_dir(); config_file.push(config_dir); config_file }; @@ -50,6 +46,7 @@ impl Settings { )) } else { let example_config = include_bytes!("../server.toml"); + create_dir_all(config_file.parent().unwrap())?; let mut file = File::create(config_file)?; file.write_all(example_config)?;