Warn if tile expiry doesn't manage to delete enough tiles
authorTom Hughes <tom@compton.nu>
Wed, 11 Sep 2013 17:54:45 +0000 (18:54 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 11 Sep 2013 17:54:45 +0000 (18:54 +0100)
cookbooks/tile/templates/default/cleanup-tiles.erb

index e58e0bdbfafb4d5995ebb6a802e0d3221c4e5b96..73baaffd9133cacca2945cc14524a8733903a882 100644 (file)
@@ -17,7 +17,7 @@ if (df($tiledir)->{per} > 90)
 
     open(TILES, "-|", "sort", "-n", $tempfile) || die "Can't open $tempfile: $!";
 
-    while (df($tiledir)->{per} > 80  && ! eof(TILES))
+    while (df($tiledir)->{per} > 80)
     {
         for my $n (1..1000)
         {
@@ -29,12 +29,20 @@ if (df($tiledir)->{per} > 90)
 
                 unlink($tile) || warn "Can't remove $tile: $!";
             }
+            else
+            {
+                goto done;
+            }
         }
     }
 
+  done:
+
     close(TILES);
 }
 
 unlink($tempfile);
 
+warn "Tile expiry finished before threshold reached" if df($tiledir)->{per} > 80;
+
 exit 0;