X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=last.pl;h=602473901f71f49dfa106ddbef2c63eada94a441;hb=c45d2eb055b006b20ae280d34aee8f871b79d456;hp=58e8a2146a0a487e18bb25192497e73e672435b2;hpb=8a306b3d0f351d8fa0efc3b8cc9b4fde45c08c0a;p=webpdf diff --git a/last.pl b/last.pl index 58e8a21..6024739 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 -

Last $real_num_last uploads

+

Last $real_show_last uploads

Back to the converter

EOF -for my $t (@thumbnails[0..$num_last-1]) { +for my $t (@thumbnails[0..$pdfweb::config::show_last-1]) { (my $descname = $t) =~ s/\.png$/.desc/; open DESC, "<$descname" or next;