summaryrefslogtreecommitdiff
path: root/lib/backupstore/HousekeepStoreAccount.cpp
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-10-31 22:09:46 +0000
committerChris Wilson <chris+github@qwirx.com>2014-10-31 22:09:46 +0000
commitd01f128b4580f312cd7ca7bf2329d80cdaced1b4 (patch)
tree3b449a8fb5491c8b274872fede6792ae92eafb05 /lib/backupstore/HousekeepStoreAccount.cpp
parente8efeb785c158581be729aa1dee122f50789ac86 (diff)
Repair the refcount database while checking accounts for errors.
Normally this will be done by housekeeping anyway, so it's not that useful, but it's good to check for it in tests, especially when testing BackupStoreCheck's ability to repair bad things that happened to the store when they involve references.
Diffstat (limited to 'lib/backupstore/HousekeepStoreAccount.cpp')
-rw-r--r--lib/backupstore/HousekeepStoreAccount.cpp31
1 files changed, 5 insertions, 26 deletions
diff --git a/lib/backupstore/HousekeepStoreAccount.cpp b/lib/backupstore/HousekeepStoreAccount.cpp
index 8defcab1..0259461e 100644
--- a/lib/backupstore/HousekeepStoreAccount.cpp
+++ b/lib/backupstore/HousekeepStoreAccount.cpp
@@ -201,37 +201,16 @@ bool HousekeepStoreAccount::DoHousekeeping(bool KeepTryingForever)
mErrorCount += info->ReportChangesTo(*pOldInfo);
info->Save();
- // We want to compare the mapNewRefs to apOldRefs before we delete any
- // files, because that will also change the reference count in a way that's not an error.
+ // Try to load the old reference count database and check whether
+ // any counts have changed. We want to compare the mapNewRefs to
+ // apOldRefs before we delete any files, because that will also change
+ // the reference count in a way that's not an error.
- // try to load the reference count database
try
{
std::auto_ptr<BackupStoreRefCountDatabase> apOldRefs =
BackupStoreRefCountDatabase::Load(account, false);
-
- int64_t MaxOldObjectId = apOldRefs->GetLastObjectIDUsed();
- int64_t MaxNewObjectId = mapNewRefs->GetLastObjectIDUsed();
-
- for (int64_t ObjectID = BACKUPSTORE_ROOT_DIRECTORY_ID;
- ObjectID < std::max(MaxOldObjectId, MaxNewObjectId);
- ObjectID++)
- {
- typedef BackupStoreRefCountDatabase::refcount_t refcount_t;
- refcount_t OldRefs = (ObjectID <= MaxOldObjectId) ?
- apOldRefs->GetRefCount(ObjectID) : 0;
- refcount_t NewRefs = (ObjectID <= MaxNewObjectId) ?
- mapNewRefs->GetRefCount(ObjectID) : 0;
-
- if (OldRefs != NewRefs)
- {
- BOX_WARNING("Reference count of object " <<
- BOX_FORMAT_OBJECTID(ObjectID) <<
- " changed from " << OldRefs <<
- " to " << NewRefs);
- mErrorCount++;
- }
- }
+ mErrorCount += mapNewRefs->ReportChangesTo(*apOldRefs);
}
catch(BoxException &e)
{