Skip to content

Commit

Permalink
fix: Config paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustin Blackman committed Mar 2, 2024
1 parent d61375b commit 2ae187a
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/configuration/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,28 @@ impl Config {
let default_backend = BackendName::Ollama.to_string();
let default_editor = EditorName::Clipboard.to_string();

#[cfg(not(target_os = "macos"))]
let mut config_path = dirs::cache_dir().unwrap().join("oatmeal/config.toml");
if !config_path.exists() {
config_path = dirs::config_local_dir()
.unwrap()
.join("oatmeal/config.toml");
}
let mut config_path = path::PathBuf::default();

#[cfg(target_os = "macos")]
let config_path =
path::PathBuf::from(env::var("HOME").unwrap()).join(".config/oatmeal/config.toml");
{
config_path =
path::PathBuf::from(env::var("HOME").unwrap()).join(".config/oatmeal/config.toml");
}

#[cfg(target_os = "windows")]
{
config_path = dirs::cache_dir().unwrap().join("oatmeal/config.toml");
}

#[cfg(target_os = "linux")]
{
config_path = dirs::cache_dir().unwrap().join("oatmeal/config.toml");
if !config_path.exists() {
config_path = dirs::config_local_dir()
.unwrap()
.join("oatmeal/config.toml");
}
}

let res = match key {
ConfigKey::Backend => &default_backend,
Expand Down

0 comments on commit 2ae187a

Please sign in to comment.