diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-04-06 19:41:26 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-04-06 19:41:26 +0000 |
commit | 5a1512912e369b8df78769a4a9ebd89c92e4556b (patch) | |
tree | e067a32e719309e126a7a4c56f6157a08a6e3138 /lib/backupstore | |
parent | 3cf9311eba9e6b8374b877eea385031936d187ba (diff) |
Fix test failures caused by failure to commit the temporary refcount DB.
Files need to be closed before renaming over them on Windows.
Diffstat (limited to 'lib/backupstore')
-rw-r--r-- | lib/backupstore/BackupStoreRefCountDatabase.cpp | 13 | ||||
-rw-r--r-- | lib/backupstore/HousekeepStoreAccount.cpp | 4 |
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/backupstore/BackupStoreRefCountDatabase.cpp b/lib/backupstore/BackupStoreRefCountDatabase.cpp index 8929b691..8b51b70a 100644 --- a/lib/backupstore/BackupStoreRefCountDatabase.cpp +++ b/lib/backupstore/BackupStoreRefCountDatabase.cpp @@ -96,15 +96,16 @@ void BackupStoreRefCountDatabase::Discard() "Cannot discard a permanent reference count database"); } - if (!mapDatabaseFile.get()) + // Under normal conditions, we should know whether the file is still + // open or not, and not Discard it unless it's open. However if the + // final rename() fails during Commit(), the file will already be + // closed, and we don't want to blow up here in that case. + if (mapDatabaseFile.get()) { - THROW_EXCEPTION_MESSAGE(CommonException, Internal, - "Reference count database is already closed"); + mapDatabaseFile->Close(); + mapDatabaseFile.reset(); } - mapDatabaseFile->Close(); - mapDatabaseFile.reset(); - if(unlink(mFilename.c_str()) != 0) { THROW_EMU_FILE_ERROR("Failed to delete temporary refcount " diff --git a/lib/backupstore/HousekeepStoreAccount.cpp b/lib/backupstore/HousekeepStoreAccount.cpp index 02e68857..6fcc3a7f 100644 --- a/lib/backupstore/HousekeepStoreAccount.cpp +++ b/lib/backupstore/HousekeepStoreAccount.cpp @@ -79,6 +79,10 @@ HousekeepStoreAccount::HousekeepStoreAccount(int AccountID, // -------------------------------------------------------------------------- HousekeepStoreAccount::~HousekeepStoreAccount() { + if(mapNewRefs.get()) + { + mapNewRefs->Discard(); + } } // -------------------------------------------------------------------------- |