If dm6 is interrupted, it can leave temporary link files in the link-dir.
These will artificially inflate the link counts, and prevent those files
from ever being deleted.
# Garbage collection
print STDERR "\nGarbage collection in '$link_dir'...";
chdir($link_dir) || die "chdir: $link_dir: $!";
# Garbage collection
print STDERR "\nGarbage collection in '$link_dir'...";
chdir($link_dir) || die "chdir: $link_dir: $!";
-print STDERR "\nRemoving files with link count < 3...";
-system("find . -type f -links -3 -print0 | xargs -0rt rm -f") and die "system: exit status $?";
+print STDERR "\nRemoving files with link count < 3 and temporary links...";
+system('find . -type f \( -links -3 -o -name ".*" \) -print0 | xargs -0rt rm -f') and die "system: exit status $?";
print STDERR "\nRemoving empty directories...";
system("find . -type d -empty -print0 | xargs -0rt rmdir -p --ignore-fail-on-non-empty") and die "system: exit status $?";
print STDERR "\nDone.\n";
print STDERR "\nRemoving empty directories...";
system("find . -type d -empty -print0 | xargs -0rt rmdir -p --ignore-fail-on-non-empty") and die "system: exit status $?";
print STDERR "\nDone.\n";