diff options
author | Simon McVittie <smcv@debian.org> | 2010-11-27 13:40:11 +0000 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2011-01-07 18:53:27 +0000 |
commit | c7bf305c81e01f9a49e110a33665cc692cfe0859 (patch) | |
tree | 6bc123ba3fed439d0c3092814353d0c5865780b1 /IkiWiki | |
parent | 8250c3a45799cecb0f3a4f48e9a660ae4e937f39 (diff) |
GC unused pages in the transient underlay
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/transient.pm | 14 |
1 files changed, 14 insertions, 0 deletions
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; |