Don't crash when config directory doesn't exist

This commit is contained in:
Roey Darwish Dror
2020-05-12 10:14:21 +03:00
parent 292d6eb1ad
commit cf34294a32

View File

@@ -126,7 +126,11 @@ impl ConfigFile {
///
/// If the configuration file does not exist the function returns the default ConfigFile.
fn read(base_dirs: &BaseDirs, config_path: Option<PathBuf>) -> Result<ConfigFile> {
let config_path = config_path.unwrap_or_else(|| Self::ensure(base_dirs).unwrap());
let config_path = if let Some(path) = config_path {
path
} else {
Self::ensure(base_dirs)?
};
let contents = fs::read_to_string(&config_path).map_err(|e| {
log::error!("Unable to read {}", config_path.display());