From efdf9717db7cc053deaae42bdf3d0a4bea3075cb Mon Sep 17 00:00:00 2001 From: Lee Ockert Date: Wed, 18 Oct 2023 18:29:20 -0400 Subject: [PATCH] Don't re-link already linked files, UI enhanced While creating hard links, check if they're already linked first. This saves SUBSTANTIAL time in Time Machine directories where many files are already hard links. Also, be clearer when running about what exactly it is we're doing with each file. --- dirdedupe.sh | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/dirdedupe.sh b/dirdedupe.sh index a2994c8..7b525b3 100755 --- a/dirdedupe.sh +++ b/dirdedupe.sh @@ -78,16 +78,24 @@ do if [ -f "${shadowfile}" ]; then masterfile="${shadowfile/#${shadowdir}/${masterdir}}" if [ -f "${masterfile}" ]; then - cmp -s "${masterfile}" "${shadowfile}" - if [ $? -eq 0 ]; then - if [ $REALLYRUN -gt 0 ]; then - echo "Linking \"${masterfile}\" <-- \"${shadowfile}\"" - ln -Pf "${masterfile}" "${shadowfile}" + if [ "${shadowfile}" -ef "${masterfile}" ]; then + echo "ID \"${masterfile}\" <-> \"${shadowfile}\"" + else + cmp -s "${masterfile}" "${shadowfile}" + if [ $? -eq 0 ]; then + if [ $REALLYRUN -gt 0 ]; then + echo "LINK \"${masterfile}\" <-- \"${shadowfile}\"" + ln -Pf "${masterfile}" "${shadowfile}" + else + echo "HYPO \"${masterfile}\" <~~ \"${shadowfile}\"" + fi else - echo "NOT linking \"${masterfile}\" <-- \"${shadowfile}\"" - fi - fi - fi + echo "MOD \"${masterfile}\" \"${shadowfile}\"" + fi # end check for file equality + fi # end check for inode equality + else + echo "NEW \"${shadowfile}\" " + fi # end check if master file exists fi done