]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/tile/templates/default/cleanup-tiles.erb
Revert "Switch web site to use MapQuest Nominatim for search"
[chef.git] / cookbooks / tile / templates / default / cleanup-tiles.erb
index 9209a2644d8116663b16cbfc60b951ba52981625..c92e538784ac0552fa7926daa35326ba4e4329e6 100644 (file)
@@ -7,17 +7,19 @@ use warnings;
 
 use File::Temp qw(tmpnam);
 use Filesys::Df;
-use LockFile::Simple qw(lock unlock);
+use LockFile::Simple;
 
 my $tiledir = shift @ARGV;
 
-lock($tiledir) || exit 0;
+my $lockmgr = LockFile::Simple->make(-autoclean => 1, -max => 1, -hold => 0, -warn => 0);
+
+$lockmgr->lock("${tiledir}/cleanup") || exit 0;
 
 my $tempfile = tmpnam();
 
 if (df($tiledir)->{per} > 90)
 {
-    system("find", $tiledir, "-xdev", "-type", "f", "-name", "*.meta", "-atime", "+35", "-fprintf", $tempfile, "%A@ %p\n");
+    system("find", $tiledir, "-xdev", "-name", "lost+found", "-prune", "-o", "-type", "f", "-name", "*.meta", "-atime", "+14", "-fprintf", $tempfile, "%A@ %p\n");
 
     open(TILES, "-|", "sort", "-n", $tempfile) || die "Can't open $tempfile: $!";
 
@@ -49,6 +51,6 @@ if (df($tiledir)->{per} > 90)
 
 unlink($tempfile);
 
-unlock($tiledir);
+$lockmgr->unlock("${tiledir}/cleanup");
 
 exit 0;