issue 150: some issues with configuration (#151)

* issue 150: some issues with configuration
This commit is contained in:
Christian Visintin
2023-02-28 10:45:07 +01:00
committed by GitHub
parent 67df3dc76a
commit 1ecef6fc16
4 changed files with 33 additions and 9 deletions
+7 -6
View File
@@ -25,12 +25,13 @@ pub fn init_config_dir() -> Result<Option<PathBuf>, String> {
// Append termscp dir
p.push("termscp/");
// If directory doesn't exist, create it
match p.exists() {
true => Ok(Some(p)),
false => match std::fs::create_dir(p.as_path()) {
Ok(_) => Ok(Some(p)),
Err(err) => Err(err.to_string()),
},
if p.exists() {
return Ok(Some(p));
}
// directory doesn't exist; create dir recursively
match std::fs::create_dir_all(p.as_path()) {
Ok(_) => Ok(Some(p)),
Err(err) => Err(err.to_string()),
}
} else {
Ok(None)