summaryrefslogtreecommitdiff
path: root/lib/backupstore
diff options
context:
space:
mode:
Diffstat (limited to 'lib/backupstore')
-rw-r--r--lib/backupstore/BackupStoreContext.cpp16
-rw-r--r--lib/backupstore/BackupStoreContext.h1
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;