Don't overwrite files without the -f/--force flag

This commit is contained in:
Emi Simpson 2022-08-17 23:03:33 -04:00
parent c69bbec8df
commit 8345de8f0c
Signed by: Emi
GPG key ID: A12F2C2FFDC3D847
2 changed files with 5 additions and 0 deletions

View file

@ -253,6 +253,7 @@ fn download(server: &str, args: DownloadArgs) -> Result<(), AviaryDownloadError>
.write(true)
.truncate(true)
.create(true)
.create_new(!args.force)
.open(&path)
.map_err(|e| match e.kind() {
io::ErrorKind::PermissionDenied =>

View file

@ -61,4 +61,8 @@ pub struct DownloadArgs {
///
/// A directory will be generated based on the name of the gallery if this is not set
pub output: Option<PathBuf>,
#[argh(switch, short='f')]
/// overwrite any existing files in the output directory
pub force: bool,
}