mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-03-07 11:59:59 +03:00
clear config, when unable to parse
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user