diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-04-09 22:14:57 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-04-09 22:14:57 +0000 |
commit | 7175691ff83781a2c733540f465298e78f7ad93f (patch) | |
tree | 5ae72ce170213c4132a4d19fb7828ac552fe3bc2 | |
parent | 65694550d9352879befaa80a4dc9553e8d359310 (diff) |
Don't require passing the object ID into BackupStoreContext::SaveDirectory.
Passing the wrong object ID would just result in an assertion being thrown
(in debug builds) or silently doing the wrong thing (in release builds). I
can't see any useful use for this extra parameter, since we can get the
container ID from the directory anyway.
-rw-r--r-- | lib/backupstore/BackupStoreContext.cpp | 35 | ||||
-rw-r--r-- | lib/backupstore/BackupStoreContext.h | 2 |
2 files changed, 17 insertions, 20 deletions
diff --git a/lib/backupstore/BackupStoreContext.cpp b/lib/backupstore/BackupStoreContext.cpp index c6d45324..33c2a660 100644 --- a/lib/backupstore/BackupStoreContext.cpp +++ b/lib/backupstore/BackupStoreContext.cpp @@ -697,7 +697,7 @@ int64_t BackupStoreContext::AddFile(IOStream &rFile, int64_t InDirectory, } // Write the directory back to disc - SaveDirectory(dir, InDirectory); + SaveDirectory(dir); // Commit the old version's new patched version, now that the directory safely reflects // the state of the files on disc. @@ -832,7 +832,7 @@ bool BackupStoreContext::DeleteFile(const BackupStoreFilename &rFilename, int64_ if(madeChanges) { // Save the directory back - SaveDirectory(dir, InDirectory); + SaveDirectory(dir); SaveStoreInfo(false); } } @@ -910,7 +910,7 @@ bool BackupStoreContext::UndeleteFile(int64_t ObjectID, int64_t InDirectory) if(madeChanges) { // Save the directory back - SaveDirectory(dir, InDirectory); + SaveDirectory(dir); // Modify the store info, and write mapStoreInfo->ChangeBlocksInDeletedFiles(blocksDel); @@ -953,22 +953,19 @@ void BackupStoreContext::RemoveDirectoryFromCache(int64_t ObjectID) // -------------------------------------------------------------------------- // // Function -// Name: BackupStoreContext::SaveDirectory(BackupStoreDirectory &, int64_t) +// Name: BackupStoreContext::SaveDirectory(BackupStoreDirectory &) // Purpose: Save directory back to disc, update time in cache // Created: 2003/09/04 // // -------------------------------------------------------------------------- -void BackupStoreContext::SaveDirectory(BackupStoreDirectory &rDir, int64_t ObjectID) +void BackupStoreContext::SaveDirectory(BackupStoreDirectory &rDir) { if(mapStoreInfo.get() == 0) { THROW_EXCEPTION(BackupStoreException, StoreInfoNotLoaded) } - if(rDir.GetObjectID() != ObjectID) - { - THROW_EXCEPTION(BackupStoreException, Internal) - } + int64_t ObjectID = rDir.GetObjectID(); try { @@ -1110,7 +1107,7 @@ int64_t BackupStoreContext::AddDirectory(int64_t InDirectory, dir.AddEntry(rFilename, ModificationTime, id, dirSize, BackupStoreDirectory::Entry::Flags_Dir, 0 /* attributes hash */); - SaveDirectory(dir, InDirectory); + SaveDirectory(dir); // Increment reference count on the new directory to one mapRefCount->AddReference(id); @@ -1196,7 +1193,7 @@ void BackupStoreContext::DeleteDirectory(int64_t ObjectID, bool Undelete) } // Save it - SaveDirectory(parentDir, InDirectory); + SaveDirectory(parentDir); // Done break; @@ -1312,7 +1309,7 @@ void BackupStoreContext::DeleteDirectoryRecurse(int64_t ObjectID, bool Undelete) // Save the directory if(changesMade) { - SaveDirectory(dir, ObjectID); + SaveDirectory(dir); } } } @@ -1353,7 +1350,7 @@ void BackupStoreContext::ChangeDirAttributes(int64_t Directory, const Streamable dir.SetAttributes(Attributes, AttributesModTime); // Save back - SaveDirectory(dir, Directory); + SaveDirectory(dir); } catch(...) { @@ -1414,7 +1411,7 @@ bool BackupStoreContext::ChangeFileAttributes(const BackupStoreFilename &rFilena } // Save back - SaveDirectory(dir, InDirectory); + SaveDirectory(dir); } catch(...) { @@ -1675,7 +1672,7 @@ void BackupStoreContext::MoveObject(int64_t ObjectID, int64_t MoveFromDirectory, } // Save the directory back - SaveDirectory(dir, MoveFromDirectory); + SaveDirectory(dir); } catch(...) { @@ -1769,7 +1766,7 @@ void BackupStoreContext::MoveObject(int64_t ObjectID, int64_t MoveFromDirectory, } // Save back - SaveDirectory(to, MoveToDirectory); + SaveDirectory(to); } // Thirdly... remove them from the first directory -- but if it fails, attempt to delete them from the to directory @@ -1785,7 +1782,7 @@ void BackupStoreContext::MoveObject(int64_t ObjectID, int64_t MoveFromDirectory, } // Save back - SaveDirectory(from, MoveFromDirectory); + SaveDirectory(from); } catch(...) { @@ -1801,7 +1798,7 @@ void BackupStoreContext::MoveObject(int64_t ObjectID, int64_t MoveFromDirectory, } // Save back - SaveDirectory(to, MoveToDirectory); + SaveDirectory(to); // Throw the error throw; @@ -1817,7 +1814,7 @@ void BackupStoreContext::MoveObject(int64_t ObjectID, int64_t MoveFromDirectory, change.SetContainerID(MoveToDirectory); // Save it back - SaveDirectory(change, *i); + SaveDirectory(change); } } catch(...) diff --git a/lib/backupstore/BackupStoreContext.h b/lib/backupstore/BackupStoreContext.h index 62b828df..2299c0fd 100644 --- a/lib/backupstore/BackupStoreContext.h +++ b/lib/backupstore/BackupStoreContext.h @@ -171,7 +171,7 @@ public: private: void MakeObjectFilename(int64_t ObjectID, std::string &rOutput, bool EnsureDirectoryExists = false); BackupStoreDirectory &GetDirectoryInternal(int64_t ObjectID); - void SaveDirectory(BackupStoreDirectory &rDir, int64_t ObjectID); + void SaveDirectory(BackupStoreDirectory &rDir); void RemoveDirectoryFromCache(int64_t ObjectID); void ClearDirectoryCache(); void DeleteDirectoryRecurse(int64_t ObjectID, bool Undelete); |