fix: Create the vaults file if it's not exist (#60)
All checks were successful
Write changelog / write-changelog (push) Successful in 4s
Rust CI / Rust CI (push) Successful in 2m26s

Reviewed-on: #60
Co-authored-by: Awiteb <a@4rs.nl>
Co-committed-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb 2024-06-28 18:24:41 +02:00 committed by awiteb
parent d6c38c3203
commit 81a360519e

View file

@ -122,11 +122,16 @@ impl Cli {
log::info!("Using the given vaults file"); log::info!("Using the given vaults file");
if let Some(parent) = path.parent() { if let Some(parent) = path.parent() {
if parent.to_str() != Some("") && !parent.exists() { if parent.to_str() != Some("") && !parent.exists() {
log::info!("Creating the parent vaults file directory"); log::info!(
"Creating the parent vaults file directory: {}",
parent.display()
);
fs::create_dir_all(parent)?; fs::create_dir_all(parent)?;
} }
} }
fs::File::create(&path)?; if !path.exists() {
fs::File::create(&path)?;
}
path path
} else { } else {
log::info!("Using the default vaults file"); log::info!("Using the default vaults file");