From cf34294a32d849a7ef248a4c71a51f1fc08df1ca Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Tue, 12 May 2020 10:14:21 +0300 Subject: [PATCH] Don't crash when config directory doesn't exist --- src/config.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index d8c3d421..2dc7b022 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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) -> Result { - 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());