equal
deleted
inserted
replaced
93 } |
93 } |
94 |
94 |
95 sub purge_unused { |
95 sub purge_unused { |
96 my ($dir, %block) = @_; |
96 my ($dir, %block) = @_; |
97 |
97 |
98 my ($total, $done); |
98 my ($total, $done, $t0); |
99 verbose("# pass 1 - checking for unused blocks"); |
99 verbose("# pass 1 - checking for unused blocks"); |
100 verbose("# estimating file count"); |
100 verbose("# estimating file count"); |
101 |
101 |
102 # calculate the number of files we expect |
102 # calculate the number of files we expect |
103 find( |
103 find( |
111 "$dir/data" |
111 "$dir/data" |
112 ); |
112 ); |
113 verbose("# got $total blocks/files"); |
113 verbose("# got $total blocks/files"); |
114 |
114 |
115 # progress |
115 # progress |
|
116 $t0 = time; |
116 local $SIG{ALRM} = sub { |
117 local $SIG{ALRM} = sub { |
117 return alarm 1 if not $done; |
118 return alarm 1 if not $done; |
118 my $speed = $done / (time - $^T + 1); |
119 my $speed = $done / (time - $t0 + 1); |
119 verbose sprintf "# pass 1 done %5.1f%% | %25s (%*d of %d blocks)", |
120 verbose sprintf "# pass 1 done %5.1f%% | %25s (%*d of %d blocks)", |
120 100 * ($done / $total), |
121 100 * ($done / $total), |
121 scalar(localtime($^T + $speed * ($total - $done))), |
122 scalar(localtime $t0 + $total/$speed), |
122 length($total) => $done, |
123 length($total) => $done, |
123 $total; |
124 $total; |
124 alarm 5; |
125 alarm 5; |
125 }; |
126 }; |
126 $SIG{ALRM}->(); |
127 $SIG{ALRM}->(); |
181 sub check_images { |
182 sub check_images { |
182 my ($dir, %block) = @_; |
183 my ($dir, %block) = @_; |
183 |
184 |
184 my $total = grep { $_ ne "" } keys(%block); |
185 my $total = grep { $_ ne "" } keys(%block); |
185 my $done = 0; |
186 my $done = 0; |
|
187 my $t0 = time; |
186 |
188 |
187 verbose("# pass 2 - checking image completeness"); |
189 verbose("# pass 2 - checking image completeness"); |
188 |
190 |
189 # progress |
191 # progress |
190 local $SIG{ALRM} = sub { |
192 local $SIG{ALRM} = sub { |
191 return alarm 1 if not $done; |
193 return alarm 1 if not $done; |
192 my $speed = $done / (time - $^T + 1); |
194 my $speed = $done / (time - $t0 + 1); |
193 verbose sprintf "# pass 2 done %5.1f%% | %25s (%*d of %d blocks)", |
195 verbose sprintf "# pass 2 done %5.1f%% | %25s (%*d of %d blocks)", |
194 100 * $done / $total, |
196 100 * $done / $total, |
195 scalar(localtime($^T + ($total - $done) * $speed)), |
197 scalar(localtime $t0 + $total/$speed), |
196 length($total) => $done, |
198 length($total) => $done, |
197 $total; |
199 $total; |
198 alarm 5; |
200 alarm 5; |
199 }; |
201 }; |
200 $SIG{ALRM}->(); |
202 $SIG{ALRM}->(); |