21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
33 Minimum age in days of the target directory
34 (measured with C<-M>).
40 We scan the C<solved> directory for families of files for one vdistro.
41 If there is no corresponding tarfile or directory in the reports
42 collection area, we remove it.
44 The first run on 20171230 removed about 3.5 G.
50 use lib
"$FindBin::Bin/../CPAN-Blame/lib";
53 use File
::Basename
qw(dirname);
54 use File
::Path
qw(mkpath);
59 use Hash
::Util
qw(lock_keys);
60 use CPAN
::Blame
::Config
::Cnntp
;
63 lock_keys
%Opt, map { /([^=|!]+)/ } @opt;
70 $Opt{minage
} //= 1440;
72 my $root = $CPAN::Blame
::Config
::Cnntp
::Config
->{ctgetreports_dir
} || die;
73 my $workdir = $CPAN::Blame
::Config
::Cnntp
::Config
->{solver_vardir
} || die;
74 $workdir =~ s
"$"/workdir/solved
";
75 opendir my $dh, $workdir or die;
77 DIRENT: for my $dirent (readdir $dh) {
78 # CPAN-Mini-Indexed-0.01_01.1.slv.LCK, CPAN-Mini-Indexed-0.03_01.2.slv, CPAN-Mini-Indexed-0.03_01.2.slvdv.gz, CPAN-Mini-Indexed-0.03_01.2.yml
79 my($stem) = $dirent =~ /(.+)(?:\.slv\.LCK|\.slv|\.slvdv.gz|\.yml)$/ or next;
80 next if $seen{$stem}++;
81 my $troot = sprintf "%s/%s/%s", $root, substr($stem,0,1), $stem;
82 my @trcand = grep { -e $_ } glob("$troot\
{,.tar
}");
83 # if (-e "$troot.tar
") {
85 my $trcand = scalar @trcand;
86 # warn " has
$trcand tarballs
or something
: @trcand\n";
89 my @cand = grep { -e $_ } glob("$workdir/$stem\
{.slv
.LCK
,.slv
,.slvdv
.gz
,.yml
}");
91 warn "Warning
: no cand
for $stem, skipping
";
94 if (map { /[\*\?]/ } @cand) {
95 die "Illegal filename with
glob character discovered
: @cand";
97 # system "ls
-l
@cand";
98 my @ages = sort { $a <=> $b } map { -M $_ } grep { !/\.slv\.LCK$/ } @cand;
100 @ages = sort { $a <=> $b } map { -M $_ } @cand;
102 if ($ages[0] < $Opt{minage}) {
103 # warn " is younger than
$Opt{minage
} days
($ages[0])\n";
107 warn " about to
unlink @cand\n";
108 unlink @cand or die "Could
not unlink: $!";
110 last if $Opt{max} && ++$i >= $Opt{max};
115 # cperl-indent-level: 4