[Box Backup-commit] COMMIT r3625 - in box/trunk: lib/backupstore test/backupstore
subversion at boxbackup.org
subversion at boxbackup.org
Sat Aug 15 11:58:00 BST 2015
Author: chris
Date: 2015-08-15 10:57:59 +0000 (Sat, 15 Aug 2015)
New Revision: 3625
Modified:
box/trunk/lib/backupstore/BackupCommands.cpp
box/trunk/lib/backupstore/BackupStoreException.txt
box/trunk/test/backupstore/testbackupstore.cpp
Log:
Improve exception handling on backup store side.
Add a new exception code to represent an object being completely missing (not
found on the store at all), separate from not being found in a particular
directory.
Improve mapping of server-side exceptions to protocol error messages returned
to the client.
Add handling for missing exceptions, such as
BackupStoreException::PatchChainInfoBadInDirectory, and the new
BackupStoreException::ObjectDoesNotExist.
Fix mapping for BackupStoreException::CouldNotFindEntryInDirectory to make it
distinguistable from BackupStoreException::ObjectDoesNotExist.
Modified: box/trunk/lib/backupstore/BackupCommands.cpp
===================================================================
--- box/trunk/lib/backupstore/BackupCommands.cpp 2015-08-08 21:13:48 UTC (rev 3624)
+++ box/trunk/lib/backupstore/BackupCommands.cpp 2015-08-15 10:57:59 UTC (rev 3625)
@@ -85,12 +85,20 @@
}
else if(e.GetSubType() == BackupStoreException::CouldNotFindEntryInDirectory)
{
- return PROTOCOL_ERROR(Err_DoesNotExist);
+ return PROTOCOL_ERROR(Err_DoesNotExistInDirectory);
}
else if(e.GetSubType() == BackupStoreException::NameAlreadyExistsInDirectory)
{
return PROTOCOL_ERROR(Err_TargetNameExists);
}
+ else if(e.GetSubType() == BackupStoreException::ObjectDoesNotExist)
+ {
+ return PROTOCOL_ERROR(Err_DoesNotExist);
+ }
+ else if(e.GetSubType() == BackupStoreException::PatchChainInfoBadInDirectory)
+ {
+ return PROTOCOL_ERROR(Err_PatchConsistencyError);
+ }
}
throw;
@@ -779,8 +787,29 @@
}
// Load up the directory
- const BackupStoreDirectory &rdir(rContext.GetDirectory(dirID));
+ const BackupStoreDirectory *pDir;
+ try
+ {
+ pDir = &rContext.GetDirectory(dirID);
+ }
+ catch(BackupStoreException &e)
+ {
+ if(e.GetSubType() == BackupStoreException::ObjectDoesNotExist)
+ {
+ // If this can't be found, then there is a problem...
+ // tell the caller it can't be found.
+ return std::auto_ptr<BackupProtocolMessage>(
+ new BackupProtocolObjectName(
+ BackupProtocolObjectName::NumNameElements_ObjectDoesntExist,
+ 0, 0, 0));
+ }
+
+ throw;
+ }
+
+ const BackupStoreDirectory& rdir(*pDir);
+
// Find the element in this directory and store it's name
if(objectID != ObjectID_DirectoryOnly)
{
Modified: box/trunk/lib/backupstore/BackupStoreException.txt
===================================================================
--- box/trunk/lib/backupstore/BackupStoreException.txt 2015-08-08 21:13:48 UTC (rev 3624)
+++ box/trunk/lib/backupstore/BackupStoreException.txt 2015-08-15 10:57:59 UTC (rev 3625)
@@ -72,3 +72,4 @@
MultiplyReferencedObject 69 Attempted to modify an object with multiple references, should be uncloned first
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.
Modified: box/trunk/test/backupstore/testbackupstore.cpp
===================================================================
--- box/trunk/test/backupstore/testbackupstore.cpp 2015-08-08 21:13:48 UTC (rev 3624)
+++ box/trunk/test/backupstore/testbackupstore.cpp 2015-08-15 10:57:59 UTC (rev 3625)
@@ -1723,7 +1723,7 @@
BACKUPSTORE_ROOT_DIRECTORY_ID, subdirid,
BackupProtocolMoveObject::Flags_MoveAllWithSameName,
newName),
- Err_DoesNotExist);
+ Err_DoesNotExistInDirectory);
BackupStoreFilenameClear newName("moved-files");
TEST_COMMAND_RETURNS_ERROR(*apProtocol,
QueryMoveObject(
@@ -1732,7 +1732,7 @@
subdirid,
BackupProtocolMoveObject::Flags_MoveAllWithSameName,
newName),
- Err_DoesNotExist);
+ Err_DoesNotExistInDirectory);
TEST_COMMAND_RETURNS_ERROR(*apProtocol,
QueryMoveObject(
uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
@@ -1740,7 +1740,7 @@
subdirid,
BackupProtocolMoveObject::Flags_MoveAllWithSameName,
newName),
- Err_DoesNotExist);
+ Err_DoesNotExistInDirectory);
}
// File exists, but not in this directory (we just moved it)
@@ -1750,7 +1750,7 @@
subdirid,
BackupProtocolMoveObject::Flags_MoveAllWithSameName,
newName),
- Err_DoesNotExist);
+ Err_DoesNotExistInDirectory);
// Moving file to same directory that it's already in,
// with the same name
More information about the Boxbackup-commit
mailing list