From f32549a8a32df19582565ee129de4afadd7f72ca Mon Sep 17 00:00:00 2001 From: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:29:39 +1100 Subject: [PATCH] Fix self-install failure reflink_or_copy now fails if the dest already exists https://github.com/cargo-bins/reflink-copy/commit/9e0b2cf4278146c19782ea458a73a39871d21dd5 Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com> --- crates/atomic-file-install/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/atomic-file-install/src/lib.rs b/crates/atomic-file-install/src/lib.rs index 63ad812a..4f444262 100644 --- a/crates/atomic-file-install/src/lib.rs +++ b/crates/atomic-file-install/src/lib.rs @@ -33,6 +33,7 @@ fn copy_to_tempfile(src: &Path, dst: &Path) -> io::Result { src.display(), tempfile.path().display() ); + fs::remove_file(tempfile.path())?; // src and dst is likely to be on the same filesystem. // Uses reflink if the fs support it, or fallback to // `fs::copy` if it doesn't support it or it is not on the