Add garbage collection at the end of each run.
authorZygo Blaxell <zblaxell@esightcorp.com>
Thu, 13 May 2010 20:41:30 +0000 (16:41 -0400)
committerZygo Blaxell <zblaxell@esightcorp.com>
Thu, 13 May 2010 20:41:30 +0000 (16:41 -0400)
You can trivially invoke the garbage collector by redirecting stdin
to /dev/null.

dm6

diff --git a/dm6 b/dm6
index c6f93d906e94025621b230a6baa07e83dda44a5f..874534fac260f177fd174250296d0a872fb16aa3 100755 (executable)
--- a/dm6
+++ b/dm6
@@ -186,6 +186,15 @@ while (<STDIN>) {
        warn "$file: $@" if $@;
 }
 
        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__
 exit(0);
 
 __END__