diff options
| author | sigoden <sigoden@gmail.com> | 2023-03-06 10:47:50 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-06 10:47:50 +0800 |
| commit | 056f38428c385da300f007e7cf0a37b87cd077c7 (patch) | |
| tree | 63b1b2c1080428fe1ca6abfd1e2c387f23ee9e6d | |
| parent | ffa444399fc6699aaf7e0a19086411a7010d9392 (diff) | |
| download | aichat-056f38428c385da300f007e7cf0a37b87cd077c7.tar.gz | |
fix: $AI_CONFIG_DIR points to the parent directory (#25)
| -rw-r--r-- | src/config.rs | 9 |
1 files 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()) |
