diff --git a/cosmic-config/src/lib.rs b/cosmic-config/src/lib.rs index e408eac54d0..3a3b05d0fc8 100644 --- a/cosmic-config/src/lib.rs +++ b/cosmic-config/src/lib.rs @@ -322,23 +322,22 @@ impl ConfigGet for Config { fn get(&self, key: &str) -> Result { match self.get_local(key) { Ok(value) => Ok(value), - Err(Error::NotFound) => self.get_system_default(key), + Err(Error::NoConfigDirectory | Error::NotFound) => self.get_system_default(key), Err(why) => Err(why), } } fn get_local(&self, key: &str) -> Result { // If key path exists - match self.key_path(key) { - Ok(key_path) if key_path.is_file() => { - // Load user override - let data = fs::read_to_string(key_path) - .map_err(|err| Error::GetKey(key.to_string(), err))?; - - Ok(ron::from_str(&data)?) - } - - _ => Err(Error::NotFound), + let key_path = self.key_path(key)?; + if key_path.is_file() { + // Load user override + let data = + fs::read_to_string(key_path).map_err(|err| Error::GetKey(key.to_string(), err))?; + + Ok(ron::from_str(&data)?) + } else { + Err(Error::NotFound) } }