chiark / gitweb /
remove stale caches based on MD5 of rrdtool args
[rrd-graphs.git] / cgi
diff --git a/cgi b/cgi
index 5133ffb9d5f36708fd32b447e83c8002b22844f2..1d29b1d91a7e64fb6f6ce079b899e7305dc79249 100755 (executable)
--- a/cgi
+++ b/cgi
@@ -4,6 +4,7 @@ use strict qw(vars);
 use CGI::SpeedyCGI qw/:standard -no_xhtml/;
 use CGI qw/:standard -no_xhtml/;
 use POSIX;
+use MD5;
 
 sub fail ($) {
     print(header(-status=>500),
@@ -411,9 +412,6 @@ if (defined $elem) {
     my $end= $g->{TimeRanges}[$sloth];
     die unless defined $end;
 
-    my $cacheid= "$section!$group!$elem!$sloth!$width!$height";
-    my $cachepath= "cache/$cacheid.png";
-
     my @args= @{ $g->{Args} };
     s,\<interval/(\d+)\>, $end/$1 ,ge foreach @args;
     unshift @args, qw(--end now --start), "end-${end}s";
@@ -425,6 +423,10 @@ if (defined $elem) {
     unshift @args, '-t', $title, '-w',$width, '-h',$height;
     unshift @args, qw(-a PNG --full-size-mode);
 
+    my $cacheid= "$section!$group!$elem!$sloth!$width!$height!";
+    $cacheid .= unpack "H*", MD5->hash(join '\0', @args);
+    my $cachepath= "cache/$cacheid.png";
+
     if (param('debug')) {
         print((join "\n",@args),"\n"); exit 0;
     }