--- a/bin/imager.check Wed Aug 03 10:41:51 2011 +0200
+++ b/bin/imager.check Tue Aug 16 11:04:58 2011 +0200
@@ -95,7 +95,7 @@
sub purge_unused {
my ($dir, %block) = @_;
- my ($total, $done);
+ my ($total, $done, $t0);
verbose("# pass 1 - checking for unused blocks");
verbose("# estimating file count");
@@ -106,18 +106,20 @@
opendir(my $dh => $_);
map { $total++ if not $_ ~~ [qw<. ..>] and length > 8 } readdir $dh;
closedir($dh);
+ $File::Find::prune = $_ =~ /^[\d[a-f]{3}$/; # FIXME should be configurable
},
"$dir/data"
);
verbose("# got $total blocks/files");
# progress
+ $t0 = time;
local $SIG{ALRM} = sub {
return alarm 1 if not $done;
- my $speed = $done / (time - $^T + 1);
+ my $speed = $done / (time - $t0 + 1);
verbose sprintf "# pass 1 done %5.1f%% | %25s (%*d of %d blocks)",
100 * ($done / $total),
- scalar(localtime($^T + $speed * ($total - $done))),
+ scalar(localtime $t0 + $total/$speed),
length($total) => $done,
$total;
alarm 5;
@@ -182,16 +184,17 @@
my $total = grep { $_ ne "" } keys(%block);
my $done = 0;
+ my $t0 = time;
verbose("# pass 2 - checking image completeness");
# progress
local $SIG{ALRM} = sub {
return alarm 1 if not $done;
- my $speed = $done / (time - $^T + 1);
+ my $speed = $done / (time - $t0 + 1);
verbose sprintf "# pass 2 done %5.1f%% | %25s (%*d of %d blocks)",
100 * $done / $total,
- scalar(localtime($^T + ($total - $done) * $speed)),
+ scalar(localtime $t0 + $total/$speed),
length($total) => $done,
$total;
alarm 5;