diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-23 18:15:36 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-23 18:15:36 +0200 |
commit | 834536721ce27ebfb8d73ae529d0f446725b3a4d (patch) | |
tree | bb62f1ce1b7db92da56adf69684cc14bac3e4649 /src/config | |
parent | fix(config/from_filesystem): Just load an empty config, if there isn't one (diff) | |
download | yt-834536721ce27ebfb8d73ae529d0f446725b3a4d.tar.gz yt-834536721ce27ebfb8d73ae529d0f446725b3a4d.zip |
fix(config/from_filesystem): Only create the parent of config paths
Otherwise, it would create a `videos.sqlite` *directory*, which is obviously not ideal.
Diffstat (limited to '')
-rw-r--r-- | src/config/default.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/config/default.rs b/src/config/default.rs index 131c289..e99b255 100644 --- a/src/config/default.rs +++ b/src/config/default.rs @@ -33,8 +33,10 @@ fn get_config_path(name: &'static str) -> Result<PathBuf> { pub(super) fn create_path(path: PathBuf) -> Result<PathBuf> { if !path.exists() { - std::fs::create_dir_all(&path) - .with_context(|| format!("Failed to create the '{}' directory", path.display()))? + if let Some(parent) = path.parent() { + std::fs::create_dir_all(&parent) + .with_context(|| format!("Failed to create the '{}' directory", path.display()))? + } } Ok(path) |