summaryrefslogtreecommitdiff
path: root/lib/backupstore
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2015-05-06 21:29:39 +0000
committerChris Wilson <chris+github@qwirx.com>2015-05-06 21:29:39 +0000
commit41b716a473e2efae0993a0dc323cd786c329ff7a (patch)
tree9df7107d27deb5a3690f83be3d91454334f4e071 /lib/backupstore
parentcd0ff15b1941f997faa500962b0bfc1581501010 (diff)
Fix missing account lock while checking for errors.
The old assertion, that the write lock file exists before starting checking, was erroneously passing before when no lock was held, because the lockfile was never deleted. Now that we delete it when unlocking the account, this started causing test failures. Changed the way that accounts are checked for errors to use a function that acquires a write lock first, and modified test to disconnect open clients before starting checking the account, to fix it.
Diffstat (limited to 'lib/backupstore')
-rw-r--r--lib/backupstore/BackupStoreAccounts.cpp14
-rw-r--r--lib/backupstore/BackupStoreAccounts.h3
-rw-r--r--lib/backupstore/StoreTestUtils.cpp3
3 files changed, 15 insertions, 5 deletions
diff --git a/lib/backupstore/BackupStoreAccounts.cpp b/lib/backupstore/BackupStoreAccounts.cpp
index 5f51917b..d1c7430f 100644
--- a/lib/backupstore/BackupStoreAccounts.cpp
+++ b/lib/backupstore/BackupStoreAccounts.cpp
@@ -594,7 +594,8 @@ bool BackupStoreAccountsControl::OpenAccount(int32_t ID, std::string &rRootDirOu
return true;
}
-int BackupStoreAccountsControl::CheckAccount(int32_t ID, bool FixErrors, bool Quiet)
+int BackupStoreAccountsControl::CheckAccount(int32_t ID, bool FixErrors, bool Quiet,
+ bool ReturnNumErrorsFound)
{
std::string rootDir;
int discSetNum;
@@ -612,8 +613,15 @@ int BackupStoreAccountsControl::CheckAccount(int32_t ID, bool FixErrors, bool Qu
// Check it
BackupStoreCheck check(rootDir, discSetNum, ID, FixErrors, Quiet);
check.Check();
-
- return check.ErrorsFound()?1:0;
+
+ if(ReturnNumErrorsFound)
+ {
+ return check.GetNumErrorsFound();
+ }
+ else
+ {
+ return check.ErrorsFound() ? 1 : 0;
+ }
}
int BackupStoreAccountsControl::CreateAccount(int32_t ID, int32_t DiscNumber,
diff --git a/lib/backupstore/BackupStoreAccounts.h b/lib/backupstore/BackupStoreAccounts.h
index 5ee67312..3c2e4210 100644
--- a/lib/backupstore/BackupStoreAccounts.h
+++ b/lib/backupstore/BackupStoreAccounts.h
@@ -76,7 +76,8 @@ public:
int PrintAccountInfo(int32_t ID);
int SetAccountEnabled(int32_t ID, bool enabled);
int DeleteAccount(int32_t ID, bool AskForConfirmation);
- int CheckAccount(int32_t ID, bool FixErrors, bool Quiet);
+ int CheckAccount(int32_t ID, bool FixErrors, bool Quiet,
+ bool ReturnNumErrorsFound = false);
int CreateAccount(int32_t ID, int32_t DiscNumber, int32_t SoftLimit,
int32_t HardLimit);
int HousekeepAccountNow(int32_t ID);
diff --git a/lib/backupstore/StoreTestUtils.cpp b/lib/backupstore/StoreTestUtils.cpp
index 18cb08ba..e0709876 100644
--- a/lib/backupstore/StoreTestUtils.cpp
+++ b/lib/backupstore/StoreTestUtils.cpp
@@ -276,7 +276,8 @@ int check_account_for_errors(Log::Level log_level)
BackupStoreAccountsControl control(*config);
int errors_fixed = control.CheckAccount(0x01234567,
true, // FixErrors
- false); // Quiet
+ false, // Quiet
+ true); // ReturnNumErrorsFound
return errors_fixed;
}