mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-03 06:38:52 +00:00
fix: get_writer removes file if it exists
This commit is contained in:
parent
deed33bb0f
commit
8341183820
1 changed files with 4 additions and 1 deletions
|
@ -4,7 +4,7 @@ use nix::{
|
||||||
sys::statvfs::{statvfs, FsFlags},
|
sys::statvfs::{statvfs, FsFlags},
|
||||||
};
|
};
|
||||||
use std::{
|
use std::{
|
||||||
fs::{self, copy, create_dir_all, remove_dir_all, File, OpenOptions},
|
fs::{self, copy, create_dir_all, remove_dir_all, remove_file, File, OpenOptions},
|
||||||
io::{BufReader, BufWriter},
|
io::{BufReader, BufWriter},
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
@ -15,6 +15,9 @@ pub fn get_writer(path: &Path) -> anyhow::Result<BufWriter<std::fs::File>> {
|
||||||
create_dir_all(parent)?;
|
create_dir_all(parent)?;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if path.is_file() || path.is_symlink() {
|
||||||
|
remove_file(path)?;
|
||||||
|
}
|
||||||
let file = OpenOptions::new()
|
let file = OpenOptions::new()
|
||||||
.write(true)
|
.write(true)
|
||||||
.create(true)
|
.create(true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue