X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=last.pl;h=3576ba9a30744991165e46c9440c9bf238874ee0;hb=50e9f3cceadc1fe03463d4d2daaeeb9bc6c0634f;hp=e668edfb799a4ab85a41a10dd19661e2531646b5;hpb=b943073892273418899c8187f9055d7faede1a0d;p=webpdf diff --git a/last.pl b/last.pl index e668edf..3576ba9 100755 --- a/last.pl +++ b/last.pl @@ -6,14 +6,24 @@ use strict; use warnings; require './config.pm'; -my $num_last = 20; - # Find the latest N PNG thumbnails. Somewhat ineffective, but I assume # we'll get to that later :-) my @thumbnails = (sort { -M $a <=> -M $b } <$pdfweb::config::outputdir/*.png>); -my $real_num_last = scalar @thumbnails; -if ($real_num_last > $num_last) { - $real_num_last = $num_last; +my $real_show_last = scalar @thumbnails; +if ($real_show_last > $pdfweb::config::show_last) { + $real_show_last = $pdfweb::config::show_last; +} + +# This is probably the simplest place to clean up files that we no longer +# need having around. +for my $t (@thumbnails[$pdfweb::config::show_last..$#thumbnails]) { + if (-M $t > $pdfweb::config::minimum_age) { + (my $base = $t) =~ s/\.png$//; + my @to_delete = <$base*>; + + warn "Deleting " . join(', ', @to_delete); + unlink @to_delete; + } } # Sorry, no HTML templating. I didn't want to pull in yet another @@ -35,12 +45,12 @@ Content-type: text/html; charset=utf-8
-