From d7c6a65bc1a534dfb7e8264064bdf04c5862464d Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 29 Aug 2015 08:46:35 +0000 Subject: Fix check for existing BackupStoreInfo file on S3 stores --- lib/backupstore/BackupAccountControl.cpp | 12 ++++++++++-- lib/backupstore/BackupStoreException.txt | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/backupstore') 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 #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. -- cgit v1.2.3