Skip to content

Commit 530ebfa

Browse files
committed
fix
1 parent e518af1 commit 530ebfa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/uu/cp/src/cp.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,13 @@ fn delete_dest_if_needed_and_allowed(
19751975
};
19761976

19771977
if delete_dest {
1978-
fs::remove_file(dest)?;
1978+
match fs::remove_file(dest) {
1979+
Ok(()) => {}
1980+
Err(err) if err.kind() == io::ErrorKind::NotFound => {
1981+
// target could have been deleted earlier (e.g. same-file with --remove-destination)
1982+
}
1983+
Err(err) => return Err(err.into()),
1984+
}
19791985
}
19801986

19811987
Ok(())

0 commit comments

Comments
 (0)