config storing

This commit is contained in:
Iaphetes 2025-03-14 09:30:43 +01:00
parent df53857426
commit 95c34fb431
3 changed files with 7 additions and 8 deletions

View file

@ -35,11 +35,11 @@ impl Default for CoreCFG {
pub fn load_config(path: Option<PathBuf>) -> Config {
match path {
Some(p) => confy::load_path(p).expect("Configuration could not be loaded"),
None => confy::load("apographe", Some("config"))
None => confy::load("apograph", Some("config"))
.ok()
.unwrap_or_else(|| {
let config: Config = Config::default();
let _ = confy::store("aphorme", Some("config"), Config::default());
let _ = confy::store("apograph", Some("config"), Config::default());
config
}),
}
@ -68,6 +68,7 @@ pub fn set_basepath(app_handle: tauri::AppHandle, path: String) -> bool {
// Lock the mutex to get mutable access:
let mut config = config.lock().unwrap();
config.core_cfg.home_path = Some(basepath);
let _ = confy::store("apograph", Some("config"), config.clone());
return true;
} else {
return false;