diff options
author | Matthias Beyer <matthias.beyer@atos.net> | 2021-09-17 09:18:38 +0200 |
---|---|---|
committer | Matthias Beyer <matthias.beyer@atos.net> | 2021-09-17 09:18:39 +0200 |
commit | 93741fda7c94662b0cec15ea1d1906a81032e1f1 (patch) | |
tree | aea13a734bd2fce27a1b84fa5eb3212b9d35b1a0 /src/commands/release.rs | |
parent | 905e4562272046d912f42f05973f48ca5ca02fd7 (diff) |
Fix: Delete target path before copying file to it
This fixes a bug: If the target file existed, but was created by another user,
the tokio::fs::copy() function was not able to overwrite it (only to empty the
file). So with this patch, we remove the file before we copy a new file to the
target location.
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Tested-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/commands/release.rs')
-rw-r--r-- | src/commands/release.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/commands/release.rs b/src/commands/release.rs index 460fbeb..50d3918 100644 --- a/src/commands/release.rs +++ b/src/commands/release.rs @@ -166,6 +166,13 @@ async fn new_release( } } + if dest_path.exists() { + debug!("Removing {} before writing new file to this path", dest_path.display()); + tokio::fs::remove_file(&dest_path) + .await + .with_context(|| anyhow!("Removing {} before writing new file to this path", dest_path.display()))?; + } + // else !dest_path.exists() tokio::fs::copy(&art_path, &dest_path) .await |