rsync icon indicating copy to clipboard operation
rsync copied to clipboard

Bug? `--remove-source-files` deletes even when source and target are the same

Open agguser opened this issue 3 years ago • 1 comments

$ touch /tmp/f
$ rsync --remove-source-files /tmp/f /tmp/
$ ls /tmp/f
ls: cannot access '/tmp/f': No such file or directory

--remove-source-files should not delete sources that are the same as targets, because targets would be deleted too! Or is there an option to prevent this already?

agguser avatar Apr 02 '22 15:04 agguser

It is just assumed that you don't run such a command at the moment. I'll note that the older, --remove-sent-files would avoid this particular deletion since it only removes files that were transferred, not files that match.

WayneD avatar Apr 11 '22 16:04 WayneD

I finally came up with a simple solution for this and checked it into git. Given the distributed nature of the sender & receiver processes, I had been thinking about solving this in weird ways usually revolving around argument analysis (which would have been a very complex tangle of code). I've instead done a much simpler enhancement to the MSG_SUCCESS messages that are passed around when the destination file is verified as done, and now a local sender has all the info it needs to make sure that it isn't going to delete the file the receiver just verified.

WayneD avatar Aug 21 '22 17:08 WayneD