use strict;
use warnings;
+use File::Basename;
use File::Temp qw(tmpnam);
use Filesys::Df;
use LockFile::Simple;
my $tiledir = shift @ARGV;
-my $lockmgr = LockFile::Simple->make(-autoclean => 1, -max => 1, -hold => 0, -warn => 0);
+my $lockmgr = LockFile::Simple->make(-autoclean => 1, -max => 1, -hold => 0, -warn => 0, -stale => 1);
$lockmgr->lock("${tiledir}/cleanup") || exit 0;
my $tempfile = tmpnam();
-if (df($tiledir)->{per} > 90)
+if (df($tiledir)->{per} > 88)
{
- system("find", $tiledir, "-name", "lost+found", "-prune", "-o", "-xdev", "-type", "f", "-name", "*.meta", "-atime", "+28", "-fprintf", $tempfile, "%A@ %p\n");
+ system("find", $tiledir, "-xdev", "-name", "lost+found", "-prune", "-o", "-type", "f", "-name", "*.meta", "-atime", "+3", "-fprintf", $tempfile, "%A@ %p\n");
open(TILES, "-|", "sort", "-n", $tempfile) || die "Can't open $tempfile: $!";
my($time,$tile) = split(/ /, $line);
unlink($tile) || warn "Can't remove $tile: $!";
+
+ for (my $dir = dirname($tile); $dir ne $tiledir; $dir = dirname($dir))
+ {
+ rmdir($dir);
+ }
}
else
{