rsync
rsync copied to clipboard
Bug? `--remove-source-files` deletes even when source and target are the same
$ 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?
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.
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.