diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-02-10 13:52:11 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-02-10 13:52:11 +0000 |
commit | 6d4016cc9d7be0bd3c8110382076cae35d9be161 (patch) | |
tree | e254d51c00c501ce30079c0f4a5fdddc4d65abce | |
parent | 31c7bfed9caa2e245377c458bc1c271eed61c5f4 (diff) |
Add a ClearDirectoryCache method to BackupStoreContext.
It's used in several places, and about to be one more.
-rw-r--r-- | lib/backupstore/BackupStoreContext.cpp | 16 | ||||
-rw-r--r-- | lib/backupstore/BackupStoreContext.h | 1 |
2 files changed, 10 insertions, 7 deletions
diff --git a/lib/backupstore/BackupStoreContext.cpp b/lib/backupstore/BackupStoreContext.cpp index db0b11c8..7548cba6 100644 --- a/lib/backupstore/BackupStoreContext.cpp +++ b/lib/backupstore/BackupStoreContext.cpp @@ -79,14 +79,20 @@ BackupStoreContext::BackupStoreContext(int32_t ClientID, // -------------------------------------------------------------------------- BackupStoreContext::~BackupStoreContext() { + ClearDirectoryCache(); +} + +void BackupStoreContext::ClearDirectoryCache() +{ // Delete the objects in the cache - for(std::map<int64_t, BackupStoreDirectory*>::iterator i(mDirectoryCache.begin()); i != mDirectoryCache.end(); ++i) + for(std::map<int64_t, BackupStoreDirectory*>::iterator i(mDirectoryCache.begin()); + i != mDirectoryCache.end(); ++i) { delete (i->second); } + mDirectoryCache.clear(); } - // -------------------------------------------------------------------------- // // Function @@ -321,11 +327,7 @@ BackupStoreDirectory &BackupStoreContext::GetDirectoryInternal(int64_t ObjectID) if(mDirectoryCache.size() > MAX_CACHE_SIZE) { // Very simple. Just delete everything! - for(std::map<int64_t, BackupStoreDirectory*>::iterator i(mDirectoryCache.begin()); i != mDirectoryCache.end(); ++i) - { - delete (i->second); - } - mDirectoryCache.clear(); + ClearDirectoryCache(); } // Get a RaidFileRead to read it diff --git a/lib/backupstore/BackupStoreContext.h b/lib/backupstore/BackupStoreContext.h index 9440950c..03f642ef 100644 --- a/lib/backupstore/BackupStoreContext.h +++ b/lib/backupstore/BackupStoreContext.h @@ -168,6 +168,7 @@ private: void SaveDirectory(BackupStoreDirectory &rDir, int64_t ObjectID); void RemoveDirectoryFromCache(int64_t ObjectID); void DeleteDirectoryRecurse(int64_t ObjectID, int64_t &rBlocksDeletedOut, bool Undelete); + void ClearDirectoryCache(); int64_t AllocateObjectID(); std::string mConnectionDetails; |