Closed benaiu closed 4 years ago
Good hint. We can add another safety net here by changing the symlink bash function to something like this:
cp_symlink() {
print_progress_prefix
echo "${COL_YELLOW}Symlinking to original: ${COL_RESET}$1"
if original_check "$1" "$2"; then
if [ -z "$DO_DRY_RUN" ]; then
# replace duplicate with symlink
mv -rf "$1" "$1.temp"
if ln -s "$2" "$1"; then
# make the symlink's mtime the same as the original
touch -mr "$2" -h "$1"
rm "$1.temp"
else
# Failed to link file, move back:
mv "$1.temp" "$1"
fi
fi
fi
}
I.e. move to temp file, then try ln and move back if that fails. Didn't test yet, but will prepare a patch when I have time.
This should be solved by 50f31945.
what happens when you want to symlink dupes to save some space on a filesystem that doesn't support links, for instance, vfs? well rmlint doesn't check if it can do those types of links, so it returns an error to the symlink command, and it removes the dupe.