From: Simon McVittie Date: Sat, 27 Nov 2010 13:40:11 +0000 (+0000) Subject: GC unused pages in the transient underlay X-Git-Tag: 3.20110225~84^2~1 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/c7bf305c81e01f9a49e110a33665cc692cfe0859?ds=inline;hp=8250c3a45799cecb0f3a4f48e9a660ae4e937f39 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;