3 # DO NOT EDIT - This file is being maintained by Chef
9 use File::Temp qw(tmpnam);
13 my $tiledir = shift @ARGV;
15 my $lockmgr = LockFile::Simple->make(-autoclean => 1, -max => 1, -hold => 0, -warn => 0, -stale => 1);
17 $lockmgr->lock("${tiledir}/cleanup") || exit 0;
19 my $tempfile = tmpnam();
21 if (df($tiledir)->{per} > 90)
23 system("find", $tiledir, "-xdev", "-name", "lost+found", "-prune", "-o", "-type", "f", "-name", "*.meta", "-atime", "+5", "-fprintf", $tempfile, "%A@ %p\n");
25 open(TILES, "-|", "sort", "-n", $tempfile) || die "Can't open $tempfile: $!";
27 while (df($tiledir)->{per} > 80)
31 if (defined(my $line = readline(TILES)))
35 my($time,$tile) = split(/ /, $line);
37 unlink($tile) || warn "Can't remove $tile: $!";
39 for (my $dir = dirname($tile); $dir ne $tiledir; $dir = dirname($dir))
55 warn "Tile expiry finished before threshold reached" if df($tiledir)->{per} > 80;
60 $lockmgr->unlock("${tiledir}/cleanup");