- $fileCnt = 0;
- $dirCnt = 0;
- $blkCnt = 0;
- $fileCntRm = 0;
- $blkCntRm = 0;
- $blkCnt2 = 0;
- $fileCntRep = 0;
- $fileRepMax = 0;
- $fileLinkMax = 0;
- $fileCntRename = 0;
- %FixList = ();
- find({wanted => \&GetPoolStats, no_chdir => 1}, "$TopDir/$pool");
- my $kb = $blkCnt / 2;
- my $kbRm = $blkCntRm / 2;
- my $kb2 = $blkCnt2 / 2;
-
- #
- # Now make sure that files with repeated checksums are still
- # sequentially numbered
- #
- foreach my $name ( sort(keys(%FixList)) ) {
- my $rmCnt = $FixList{$name} + 1;
- my $new = -1;
- for ( my $old = -1 ; ; $old++ ) {
- my $oldName = $name;
- $oldName .= "_$old" if ( $old >= 0 );
- if ( !-f $oldName ) {
- #
- # We know we are done when we have missed at least
- # the number of files that were removed from this
- # base name, plus a couple just to be sure
- #
- last if ( $rmCnt-- <= 0 );
- next;
+ for ( my $i = $poolRangeStart ; $i <= $poolRangeEnd ; $i++ ) {
+ my $dir = "$hexChars[int($i / 16)]/$hexChars[$i % 16]";
+ # print("Doing $pool/$dir\n") if ( ($i % 16) == 0 );
+ $fileCnt = 0;
+ $dirCnt = 0;
+ $blkCnt = 0;
+ $fileCntRm = 0;
+ $blkCntRm = 0;
+ $blkCnt2 = 0;
+ $fileCntRep = 0;
+ $fileRepMax = 0;
+ $fileLinkMax = 0;
+ $fileCntRename = 0;
+ %FixList = ();
+ $bpc->find({wanted => \&GetPoolStats}, "$TopDir/$pool/$dir")
+ if ( -d "$TopDir/$pool/$dir" );
+ my $kb = $blkCnt / 2;
+ my $kbRm = $blkCntRm / 2;
+ my $kb2 = $blkCnt2 / 2;
+
+ #
+ # Main BackupPC_nightly counts the top-level directory
+ #
+ $dirCnt++ if ( $opts{m} && -d "$TopDir/$pool" && $i == 0 );
+
+ #
+ # Also count the next level directories
+ #
+ $dirCnt++ if ( ($i % 16) == 0
+ && -d "$TopDir/$pool/$hexChars[int($i / 16)]" );
+
+ #
+ # We need to process all pending deletes before we do the
+ # renames
+ #
+ if ( @PendingDelete ) {
+ sleep(1);
+ processPendingDeletes(1);
+ }
+
+ #
+ # Now make sure that files with repeated checksums are still
+ # sequentially numbered
+ #
+ foreach my $name ( sort(keys(%FixList)) ) {
+ my $rmCnt = $FixList{$name} + 1;
+ my $new = -1;
+ for ( my $old = -1 ; ; $old++ ) {
+ my $oldName = $name;
+ $oldName .= "_$old" if ( $old >= 0 );
+ if ( !-f $oldName ) {
+ #
+ # We know we are done when we have missed at least
+ # the number of files that were removed from this
+ # base name, plus a couple just to be sure
+ #
+ last if ( $rmCnt-- <= 0 );
+ next;
+ }
+ my $newName = $name;
+ $newName .= "_$new" if ( $new >= 0 );
+ $new++;
+ next if ( $oldName eq $newName );
+ rename($oldName, $newName);
+ $fileCntRename++;