From 056f38428c385da300f007e7cf0a37b87cd077c7 Mon Sep 17 00:00:00 2001 From: sigoden Date: Mon, 6 Mar 2023 10:47:50 +0800 Subject: [PATCH] fix: $AI_CONFIG_DIR points to the parent directory (#25) --- src/config.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index d841fba..7e977be 100644 --- a/src/config.rs +++ b/src/config.rs @@ -89,11 +89,14 @@ impl Config { "{}_CONFIG_DIR", env!("CARGO_CRATE_NAME").to_ascii_uppercase() ); - let mut path = match env::var(env_name) { + let path = match env::var(env_name) { Ok(v) => PathBuf::from(v), - Err(_) => dirs::config_dir().ok_or_else(|| anyhow!("Not found config dir"))?, + Err(_) => { + let mut dir = dirs::config_dir().ok_or_else(|| anyhow!("Not found config dir"))?; + dir.push(env!("CARGO_CRATE_NAME")); + dir + } }; - path.push(env!("CARGO_CRATE_NAME")); if !path.exists() { create_dir_all(&path).map_err(|err| { anyhow!("Failed to create config dir at {}, {err}", path.display())