clear config, when unable to parse

This commit is contained in:
Ferdinand Schober
2026-02-08 13:27:38 +01:00
parent f01459b2a8
commit 8e96025f12

View File

@@ -444,14 +444,14 @@ impl Config {
log::info!("writing config to {:?}", &self.config_path); log::info!("writing config to {:?}", &self.config_path);
/* load the current configuration file */ /* load the current configuration file */
let current_config = match fs::read_to_string(&self.config_path) { let current_config = match fs::read_to_string(&self.config_path) {
Ok(c) => c.parse::<DocumentMut>().expect("fix me"), Ok(c) => c.parse::<DocumentMut>().unwrap_or_default(),
Err(e) => { Err(e) => {
log::info!("{:?} {e} => creating new config", self.config_path()); log::info!("{:?} {e} => creating new config", self.config_path());
Default::default() Default::default()
} }
}; };
let _current_config = let _current_config =
toml_edit::de::from_document::<ConfigToml>(current_config).expect("fixme"); toml_edit::de::from_document::<ConfigToml>(current_config).unwrap_or_default();
/* the new config */ /* the new config */
let new_config = self.config_toml.clone().unwrap_or_default(); let new_config = self.config_toml.clone().unwrap_or_default();