summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2015-08-29 08:46:35 +0000
committerChris Wilson <chris+github@qwirx.com>2015-08-29 08:46:35 +0000
commitd7c6a65bc1a534dfb7e8264064bdf04c5862464d (patch)
tree3218ad03ded7d7db7c29c72f07a9ef320a8dc93c /lib
parentace361b403a3308d3c94f05c3b099e3feabeb0fd (diff)
Fix check for existing BackupStoreInfo file on S3 stores
Diffstat (limited to 'lib')
-rw-r--r--lib/backupstore/BackupAccountControl.cpp12
-rw-r--r--lib/backupstore/BackupStoreException.txt1
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/backupstore/BackupAccountControl.cpp b/lib/backupstore/BackupAccountControl.cpp
index a76eec21..331ef841 100644
--- a/lib/backupstore/BackupAccountControl.cpp
+++ b/lib/backupstore/BackupAccountControl.cpp
@@ -13,6 +13,7 @@
#include <iostream>
#include "autogen_CommonException.h"
+#include "autogen_BackupStoreException.h"
#include "BackupAccountControl.h"
#include "BackupStoreConstants.h"
#include "BackupStoreDirectory.h"
@@ -188,10 +189,17 @@ int S3BackupAccountControl::CreateAccount(const std::string& name, int32_t SoftL
std::string info_url = GetFullURL(S3_INFO_FILE_NAME);
HTTPResponse response = GetObject(S3_INFO_FILE_NAME);
+ if(response.GetResponseCode() == HTTPResponse::Code_OK)
+ {
+ THROW_EXCEPTION_MESSAGE(BackupStoreException, AccountAlreadyExists,
+ "The BackupStoreInfo file already exists at this URL: " <<
+ info_url);
+ }
+
if(response.GetResponseCode() != HTTPResponse::Code_NotFound)
{
- mapS3Client->CheckResponse(response, std::string("The BackupStoreInfo file already "
- "exists at this URL: ") + info_url);
+ mapS3Client->CheckResponse(response, std::string("Failed to check for an "
+ "existing BackupStoreInfo file at this URL: ") + info_url);
}
BackupStoreInfo info(0, // fake AccountID for S3 stores
diff --git a/lib/backupstore/BackupStoreException.txt b/lib/backupstore/BackupStoreException.txt
index 40232a8e..efdbcf68 100644
--- a/lib/backupstore/BackupStoreException.txt
+++ b/lib/backupstore/BackupStoreException.txt
@@ -73,3 +73,4 @@ MultiplyReferencedObject 69 Attempted to modify an object with multiple referenc
CorruptReferenceCountDatabase 70 The account's refcount database is corrupt and must be rebuilt by housekeeping.
CancelledByBackgroundTask 71 The current task was cancelled on request by the background task.
ObjectDoesNotExist 72 The specified object ID does not exist in the store.
+AccountAlreadyExists 73 Tried to create an account that already exists.