Create config directory if necessary
This commit is contained in:
@@ -186,6 +186,14 @@ impl Settings {
|
|||||||
|
|
||||||
let exists = filename.exists();
|
let exists = filename.exists();
|
||||||
|
|
||||||
|
// try to create the parent directory if the file does not exist
|
||||||
|
if !exists {
|
||||||
|
if let Some(dir) = filename.parent() {
|
||||||
|
fs::create_dir_all(dir)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// start with the existing document, or a blank document
|
||||||
let mut document = if exists {
|
let mut document = if exists {
|
||||||
fs::read_to_string(filename.clone())
|
fs::read_to_string(filename.clone())
|
||||||
.context("Could not read existing configuration file")?
|
.context("Could not read existing configuration file")?
|
||||||
|
|||||||
Reference in New Issue
Block a user