]> git.sesse.net Git - webpdf/blobdiff - last.pl
Automatically clean up old output files etc. after N days (configurable).
[webpdf] / last.pl
diff --git a/last.pl b/last.pl
index 99ee2f5ac082cec37afc8165e99f241e93063d59..602473901f71f49dfa106ddbef2c63eada94a441 100755 (executable)
--- a/last.pl
+++ b/last.pl
@@ -14,6 +14,18 @@ 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
 # dependency :-)