From: Zygo Blaxell Date: Thu, 13 May 2010 20:41:30 +0000 (-0400) Subject: Add garbage collection at the end of each run. X-Git-Tag: dm6-0.20100514~5^2~8 X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=dupemerge;a=commitdiff_plain;h=79c8d21ca871e2f52d8de960cbf2534ba4509491 Add garbage collection at the end of each run. You can trivially invoke the garbage collector by redirecting stdin to /dev/null. --- diff --git a/dm6 b/dm6 index c6f93d9..874534f 100755 --- a/dm6 +++ b/dm6 @@ -186,6 +186,15 @@ while () { warn "$file: $@" if $@; } +# 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 digest inode -type f -links -3 -print0 | xargs -0 rm -f") and die "system: exit status $?"; +print STDERR "\nRemoving empty directories..."; +system("find digest inode -type d -empty -print0 | xargs -0r rmdir -p --ignore-fail-on-non-empty") and die "system: exit status $?"; +print STDERR "\nDone.\n"; + exit(0); __END__