equal
deleted
inserted
replaced
48 my $tmp = File::Temp->new; |
48 my $tmp = File::Temp->new; |
49 |
49 |
50 # load the index files, remember the latest |
50 # load the index files, remember the latest |
51 # timestamp we see |
51 # timestamp we see |
52 #tie %idx, "DB_File" => $tmp->filename; |
52 #tie %idx, "DB_File" => $tmp->filename; |
|
53 verbose("# reading index files"); |
53 my %block = get_block_list($dir); |
54 my %block = get_block_list($dir); |
54 |
55 |
55 verbose("# indexed: " |
56 verbose("# indexed: " |
56 . scalar(@{ $block{""} // [] }) |
57 . scalar(@{ $block{""} // [] }) |
57 . " images with " |
58 . " images with " |
94 sub purge_unused { |
95 sub purge_unused { |
95 my ($dir, %block) = @_; |
96 my ($dir, %block) = @_; |
96 |
97 |
97 my ($total, $done); |
98 my ($total, $done); |
98 verbose("# pass 1 - checking for unused blocks"); |
99 verbose("# pass 1 - checking for unused blocks"); |
99 verbose("# pass 1 - estimating file count"); |
100 verbose("# estimating file count"); |
100 |
101 |
101 # calculate the number of files we expect |
102 # calculate the number of files we expect |
102 find( |
103 find( |
103 sub { |
104 sub { |
104 -d or return; |
105 -d or return; |
106 map { $total++ if not $_ ~~ [qw<. ..>] and length > 8 } readdir $dh; |
107 map { $total++ if not $_ ~~ [qw<. ..>] and length > 8 } readdir $dh; |
107 closedir($dh); |
108 closedir($dh); |
108 }, |
109 }, |
109 "$dir/data" |
110 "$dir/data" |
110 ); |
111 ); |
|
112 verbose("# got $total blocks/files"); |
111 |
113 |
112 # progress |
114 # progress |
113 local $SIG{ALRM} = sub { |
115 local $SIG{ALRM} = sub { |
114 return alarm 1 if not $done; |
116 return alarm 1 if not $done; |
115 my $speed = $done / (time - $^T + 1); |
117 my $speed = $done / (time - $^T + 1); |