From: Simon McVittie Date: Sat, 27 Nov 2010 13:40:11 +0000 (+0000) Subject: GC unused pages in the transient underlay X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/commitdiff_plain/c7bf305c81e01f9a49e110a33665cc692cfe0859 GC unused pages in the transient underlay --- diff --git a/IkiWiki/Plugin/transient.pm b/IkiWiki/Plugin/transient.pm index 5764467ab..2784164f6 100644 --- a/IkiWiki/Plugin/transient.pm +++ b/IkiWiki/Plugin/transient.pm @@ -8,6 +8,7 @@ use IkiWiki 3.00; sub import { hook(type => "getsetup", id => "transient", call => \&getsetup); hook(type => "checkconfig", id => "transient", call => \&checkconfig); + hook(type => "change", id => "transient", call => \&change); } sub getsetup () { @@ -30,4 +31,17 @@ sub checkconfig () { add_underlay($transientdir); } +sub change (@) { + foreach my $file (@_) { + # if the corresponding file exists in the transient underlay + # and isn't actually being used, we can get rid of it + my $page = pagename($file); + my $casualty = "$transientdir/$page.$config{default_pageext}"; + if (srcfile($file) ne $casualty && -e $casualty) { + debug(sprintf(gettext("removing transient version of %s"), $page)); + IkiWiki::prune($casualty); + } + } +} + 1;