summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/operations/cp.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/operations/cp.rs b/src/operations/cp.rs
index 6037b67..1e5ab2e 100644
--- a/src/operations/cp.rs
+++ b/src/operations/cp.rs
@@ -45,6 +45,12 @@ pub fn copy(source_path: impl AsRef<Path>, destination_path: impl AsRef<Path>) -
fn copy_file(source_path: impl AsRef<Path>, destination_path: impl AsRef<Path>) -> WriteResult<()> {
// Only copy file if size or last modified time is different to file at destination.
if let Comparison::Different(last_modified) = compare_files(&source_path, &destination_path) {
+ // If existing file is a symlink, delete the link first else the copy will fail.
+ if let Ok(metadata) = destination_path.as_ref().symlink_metadata() {
+ if metadata.is_symlink() {
+ let _ = remove_file(&destination_path);
+ }
+ };
let copy_result = std::fs::copy(&source_path, &destination_path);
io_result_to_write_result(copy_result, &destination_path.as_ref())?;
if let Some(time) = last_modified {