diff options
author | Chris Wilson <chris+github@qwirx.com> | 2010-02-28 16:31:27 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2010-02-28 16:31:27 +0000 |
commit | 6189699f3ddec1409b1dbf3a045a595cf6ca629c (patch) | |
tree | d4c6b036a0754ac48724ca3b1d64e45cb72ce534 /bin | |
parent | edd08c6a75f455cf1bda3242ae4e7a62173a6dd2 (diff) |
Build the reference counts for a directory before we start deleting
files, to ensure that it's initialized and memory allocated for it.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/bbstored/HousekeepStoreAccount.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/bin/bbstored/HousekeepStoreAccount.cpp b/bin/bbstored/HousekeepStoreAccount.cpp index 9ed821a7..4ed33d22 100644 --- a/bin/bbstored/HousekeepStoreAccount.cpp +++ b/bin/bbstored/HousekeepStoreAccount.cpp @@ -420,7 +420,25 @@ bool HousekeepStoreAccount::ScanDirectory(int64_t ObjectID) // Add it to the list of directories to potentially delete mEmptyDirectories.push_back(dir.GetObjectID()); } - + + // Calculate reference counts first, before we start requesting + // files to be deleted. + // BLOCK + { + BackupStoreDirectory::Iterator i(dir); + BackupStoreDirectory::Entry *en = 0; + + while((en = i.Next()) != 0) + { + // This directory references this object + if (mNewRefCounts.size() <= en->GetObjectID()) + { + mNewRefCounts.resize(en->GetObjectID() + 1, 0); + } + mNewRefCounts[en->GetObjectID()]++; + } + } + // BLOCK { // Remove any files which are marked for removal as soon @@ -467,13 +485,6 @@ bool HousekeepStoreAccount::ScanDirectory(int64_t ObjectID) while((en = i.Next(BackupStoreDirectory::Entry::Flags_File)) != 0) { - // This directory references this object - if (mNewRefCounts.size() <= en->GetObjectID()) - { - mNewRefCounts.resize(en->GetObjectID() + 1, 0); - } - mNewRefCounts[en->GetObjectID()]++; - // Update recalculated usage sizes int16_t enFlags = en->GetFlags(); int64_t enSizeInBlocks = en->GetSizeInBlocks(); @@ -582,13 +593,6 @@ bool HousekeepStoreAccount::ScanDirectory(int64_t ObjectID) BackupStoreDirectory::Entry *en = 0; while((en = i.Next(BackupStoreDirectory::Entry::Flags_Dir)) != 0) { - // This parent directory references this child - if (mNewRefCounts.size() <= en->GetObjectID()) - { - mNewRefCounts.resize(en->GetObjectID() + 1, 0); - } - mNewRefCounts[en->GetObjectID()]++; - // Next level ASSERT((en->GetFlags() & BackupStoreDirectory::Entry::Flags_Dir) == BackupStoreDirectory::Entry::Flags_Dir); |