I'm trying to better understand how the --immutable flag works in practice.
Let's say I use rclone copy to copy file.txt from my local source to a remote destination. The file is successfully copied.
Later, I modify file.txt on the source and run the same rclone copy command again, this time with the --immutable flag enabled.
My expectation is that rclone should detect that file.txt on the destination has already been modified (i.e. it differs from the source) and then fail with an error or warning—and importantly, it should not replace the existing file.
Is this the correct behavior of --immutable?
Also, is there a difference between --immutable and --ignore-existing when it comes to preventing overwrites? I want to ensure that existing files are never modified during a copy operation, even if the source version has changed.
sometimes a simple test is the best way to understand.
# setup the test environment
mkdir -p ~/src
mkdir -p ~/dst
#create source file
touch ~/src/file.ext
# copy file.ext from source to dest
cp ~/src/ ~/dst/ -v
# using `--immutable`. rclone will not overwrite dest file and trigger an `ERROR`
touch ~/src/file.ext
rclone copy ~/src ~/dst --immutable -vv
ERROR : file.ext: Timestamp mismatch between immutable objects
ERROR : file.ext: Source and destination exist but do not match: immutable file modified
# using `--ignore-existing`, rclone will not modify/overwrite dest file as it already exists.
touch ~/src/file.ext
rclone copy ~/src ~/dst --ignore-existing -vv
DEBUG : file.ext: Destination exists, skipping
INFO : There was nothing to transfer