Fixed how ensuring config save directory exists
This commit is contained in:
@@ -34,7 +34,17 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned {
|
||||
let templated_config = reg.render_template(Self::template(), self).unwrap();
|
||||
|
||||
// make sure the whole directory structure actually exists
|
||||
fs::create_dir_all(custom_location.clone().unwrap_or(self.config_directory()))?;
|
||||
match custom_location.clone() {
|
||||
Some(loc) => {
|
||||
if let Some(parent_dir) = loc.parent() {
|
||||
fs::create_dir_all(parent_dir)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
None => fs::create_dir_all(self.config_directory()),
|
||||
}?;
|
||||
|
||||
fs::write(
|
||||
custom_location.unwrap_or(self.config_directory().join(Self::config_file_name())),
|
||||
templated_config,
|
||||
|
||||
Reference in New Issue
Block a user