From c7bf305c81e01f9a49e110a33665cc692cfe0859 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 27 Nov 2010 13:40:11 +0000 Subject: [PATCH] GC unused pages in the transient underlay --- IkiWiki/Plugin/transient.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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; -- 2.44.0