diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-04-09 22:15:08 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-04-09 22:15:08 +0000 |
commit | ca9ca6db582244658badc8a1ca69a253a0563104 (patch) | |
tree | 9f753f93eb8f3ac5622063796141af8ba9e05ed4 | |
parent | a33620130b6cdff94a387d414a665199dec8813d (diff) |
Add a Reopen method to BackupProtocolLocal2 for convenience.
-rw-r--r-- | lib/backupstore/BackupProtocol.h | 13 | ||||
-rw-r--r-- | test/backupstore/testbackupstore.cpp | 12 |
2 files changed, 16 insertions, 9 deletions
diff --git a/lib/backupstore/BackupProtocol.h b/lib/backupstore/BackupProtocol.h index 561c6ccd..43f3e162 100644 --- a/lib/backupstore/BackupProtocol.h +++ b/lib/backupstore/BackupProtocol.h @@ -26,6 +26,8 @@ class BackupProtocolLocal2 : public BackupProtocolLocal { private: BackupStoreContext mContext; + int32_t mAccountNumber; + bool mReadOnly; public: BackupProtocolLocal2(int32_t AccountNumber, @@ -36,7 +38,9 @@ public: // touch the Context, because it's not initialised yet! : BackupProtocolLocal(mContext), mContext(AccountNumber, (HousekeepingInterface *)NULL, - ConnectionDetails) + ConnectionDetails), + mAccountNumber(AccountNumber), + mReadOnly(ReadOnly) { mContext.SetClientHasAccount(AccountRootDir, DiscSetNumber); QueryVersion(BACKUP_STORE_SERVER_VERSION); @@ -52,6 +56,13 @@ public: mContext.ReleaseWriteLock(); return finished; } + + void Reopen() + { + QueryVersion(BACKUP_STORE_SERVER_VERSION); + QueryLogin(mAccountNumber, + mReadOnly ? BackupProtocolLogin::Flags_ReadOnly : 0); + } }; #endif // BACKUPPROTOCOL__H diff --git a/test/backupstore/testbackupstore.cpp b/test/backupstore/testbackupstore.cpp index 8b185f1e..238d6652 100644 --- a/test/backupstore/testbackupstore.cpp +++ b/test/backupstore/testbackupstore.cpp @@ -991,8 +991,7 @@ bool test_server_housekeeping() // Housekeeping should not change anything just yet protocol.QueryFinished(); TEST_THAT(run_housekeeping_and_check_account()); - protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION); - protocol.QueryLogin(0x01234567, 0); + protocol.Reopen(); TEST_THAT(check_num_files(1, 2, 0, 1)); TEST_THAT(check_num_blocks(protocol, file1_blocks, patch1_blocks + patch2_blocks, 0, @@ -1027,8 +1026,7 @@ bool test_server_housekeeping() // Housekeeping should not change anything just yet protocol.QueryFinished(); TEST_THAT(run_housekeeping_and_check_account()); - protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION); - protocol.QueryLogin(0x01234567, 0); + protocol.Reopen(); TEST_THAT(check_num_files(1, 3, 0, 1)); TEST_THAT(check_num_blocks(protocol, replaced_blocks, // current @@ -1044,8 +1042,7 @@ bool test_server_housekeeping() "14B", // replaced_blocks + file1_blocks + root_dir_blocks "2000B")); TEST_THAT(run_housekeeping_and_check_account()); - protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION); - protocol.QueryLogin(0x01234567, 0); + protocol.Reopen(); TEST_THAT(check_num_files(1, 1, 0, 1)); TEST_THAT(check_num_blocks(protocol, replaced_blocks, // current @@ -1072,8 +1069,7 @@ bool test_server_housekeeping() protocol.QueryFinished(); TEST_THAT(change_account_limits("0B", "2000B")); TEST_THAT(run_housekeeping_and_check_account()); - protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION); - protocol.QueryLogin(0x01234567, 0); + protocol.Reopen(); TEST_THAT(check_num_files(0, 0, 0, 1)); TEST_THAT(check_num_blocks(protocol, 0, 0, 0, root_dir_blocks, root_dir_blocks)); |