coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

`mv` shouldn't delete directory before it's moved/copied entirely

Open GZGavinZhao opened this issue 6 months ago • 1 comments

This only applies when mv-ing directories across different filesystems.

According to this StackOverflow post, in particular user263131's command, if I run (coreutils) mv /mnt/fs1/foo /mnt/fs2/ and I interrupt before the command is completed, the contents of /mnt/fs1/foo should stay unchanged. However, this is not behavior of uutils mv. To repro,

mkdir test
dd if=/dev/zero of=test/a bs=1M count=100
dd if=/dev/zero of=test/b bs=1M count=100
dd if=/dev/zero of=test/c bs=1M count=100
dd if=/dev/zero of=test/d bs=1M count=100
mv -g test /mnt/fs1/

Watch the progress bar and Ctrl+C after one file is moved. You will see that test only contains 3 files now. However, the behavior of mv is that all 4 files remain. You can verify this by running (coreutils) mv -v test /mnt/fs1 and Ctrl+C after one file is copied. All files in test are preserved.

GZGavinZhao avatar May 14 '25 18:05 GZGavinZhao

I can try taking a look into this

hz2 avatar May 14 '25 18:05 hz2