rclone icon indicating copy to clipboard operation
rclone copied to clipboard

symlinks support allow to create duplicate named files when moving

Open pasnox opened this issue 1 year ago • 0 comments

Recently symlinks support in master comes with a broken move support. It allow to copy different files that would be seen identical (regular file.ext and symlink file.ext.rclonelink) into the same folder. See https://github.com/rclone/rclone/pull/6337#issuecomment-2542534051

There are test cases for these which are currently skipped.

  • https://github.com/rclone/rclone/blob/0988fd9e9f77a29bd5344c0c1862d6b5e4a763e7/vfs/vfstest/file.go#L235-L237
  • https://github.com/rclone/rclone/blob/0988fd9e9f77a29bd5344c0c1862d6b5e4a763e7/vfs/vfstest/file.go#L252-L254
  • https://github.com/rclone/rclone/blob/0988fd9e9f77a29bd5344c0c1862d6b5e4a763e7/vfs/vfstest/file.go#L269-L271
  • https://github.com/rclone/rclone/blob/0988fd9e9f77a29bd5344c0c1862d6b5e4a763e7/vfs/vfstest/file.go#L286-L288

When done, remove the caveat in the docs added by 0ce2e12d9f3f6e79661cea0783cc6cfdeb848386

Demo (by ncw)

mkdir /tmp/src
rclone -vv mount --vfs-links /tmp/src/ /mnt/tmp/

Then this - looks fine

$ touch /mnt/tmp/source
$ ln -s source /mnt/tmp/symlink
$ ls -l /mnt/tmp/

total 1
-rw-rw-r-- 1 ncw ncw 0 Dec 16 10:40 source
lrw-rw-r-- 1 ncw ncw 6 Dec 16 10:40 symlink -> source

The underlying remote looks OK too

$ ls -l /tmp/src/
total 4
-rw-rw-r-- 1 ncw ncw 0 Dec 16 10:40 source
-rw-rw-r-- 1 ncw ncw 6 Dec 16 10:40 symlink.rclonelink

Now create a file with the same name

$ touch /mnt/tmp/file2
$ mv /mnt/tmp/file2 /mnt/tmp/symlink 
$ ls -l /mnt/tmp/
total 0
-rw-rw-r-- 1 ncw ncw 0 Dec 16 10:40 source
-rw-rw-r-- 1 ncw ncw 0 Dec 16 10:41 symlink

BUT this has created a duplicate file in the underlying remote - the symlink should have been overwritten by the file.

$ ls -l /tmp/src/
total 4
-rw-rw-r-- 1 ncw ncw 0 Dec 16 10:40 source
-rw-rw-r-- 1 ncw ncw 0 Dec 16 10:41 symlink
-rw-rw-r-- 1 ncw ncw 6 Dec 16 10:40 symlink.rclonelink

pasnox avatar Dec 14 '24 11:12 pasnox