diff --git a/src/types/config.rs b/src/types/config.rs index 44f566a..84b86f2 100644 --- a/src/types/config.rs +++ b/src/types/config.rs @@ -12,10 +12,11 @@ pub struct DaemonConfig { impl DaemonConfig { pub fn save_to_file(&self) -> Result<(), Box> { let config_path = get_config_path()?.join("daemon.json"); - let config_dir = config_path.parent().unwrap(); - if !config_path.exists() { - fs::create_dir_all(config_dir)?; + if let Some(config_dir) = config_path.parent() { + if !config_path.exists() { + fs::create_dir_all(config_dir)?; + } } let config_json = serde_json::to_string_pretty(self)?; @@ -63,10 +64,11 @@ impl Default for GuiConfig { impl GuiConfig { pub fn save_to_file(&mut self) -> Result<(), Box> { let config_path = get_config_path()?.join("gui.json"); - let config_dir = config_path.parent().unwrap(); - if !config_path.exists() { - fs::create_dir_all(config_dir)?; + if let Some(config_dir) = config_path.parent() { + if !config_path.exists() { + fs::create_dir_all(config_dir)?; + } } // Do not save scale factor if user does not want to