diff -r 3c71ae4facca -r bbdb8ea3079a bin/imager.save --- a/bin/imager.save Fri Jul 29 14:53:40 2011 +0200 +++ b/bin/imager.save Fri Jul 29 15:52:09 2011 +0200 @@ -15,7 +15,6 @@ use Getopt::Long; use Pod::Usage; - use constant KiB => 1024; use constant MiB => 1024 * KiB; use constant GiB => 1024 * MiB; @@ -60,18 +59,19 @@ } }, ) - and @ARGV >= 2 or pod2usage; + and @ARGV >= 2 + or pod2usage; my $dst = pop @ARGV; foreach my $src (@ARGV) { - if (my $pid = fork()) { - next; - } - elsif (not defined $pid) { - die "Can't fork: $!\n" - } - save($src, $dst); - exit; + if (my $pid = fork()) { + next; + } + elsif (not defined $pid) { + die "Can't fork: $!\n"; + } + save($src, $dst); + exit; } do 1 while wait != -1; @@ -122,7 +122,8 @@ my $speed = ($stats{written} + $stats{skipped}) / (time - $^T + 1); say sprintf "# %*s done %5.1f%% | %24s (%*d of $stats{todo}, written %*d, skipped %*d)", - (sort {$a<=>$b} map { length basename $_ } @ARGV)[-1] => basename($src), + (sort { $a <=> $b } map { length basename $_ } @ARGV)[-1] => + basename($src), 100 * (($stats{written} + $stats{skipped}) / $stats{todo}), ($speed ? (scalar localtime($^T + $stats{todo} / $speed)) : ""), length($stats{todo}) => $stats{written} + $stats{skipped}, @@ -133,10 +134,10 @@ $SIG{ALRM}->(); while (my $buffer = <$in>) { - my ($file, $ext, $cs); - $file = $cs = md5_hex($buffer); - $file =~ s/(?(?...).*)/$+{prefix}\/$+{fn}/g; - $ext = $o{compress} ? ".gz" : ""; + my ($file, $ext, $cs); + $file = $cs = md5_hex($buffer); + $file =~ s/(?(?...).*)/$+{prefix}\/$+{fn}/g; + $ext = $o{compress} ? ".gz" : ""; # the extension we do not put into the index my $log = sprintf "%12d %s %s" => ($. - 1), $cs, $file;