[Box Backup-commit] COMMIT r2179 - box/trunk/bin/bbstored

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Wed May 28 15:37:13 BST 2008


Author: chris
Date: 2008-05-28 15:37:13 +0100 (Wed, 28 May 2008)
New Revision: 2179

Modified:
   box/trunk/bin/bbstored/BackupCommands.cpp
Log:
Catch exception on reading a directory that doesn't exist, and return a 
protocol error message instead.


Modified: box/trunk/bin/bbstored/BackupCommands.cpp
===================================================================
--- box/trunk/bin/bbstored/BackupCommands.cpp	2008-05-28 14:35:20 UTC (rev 2178)
+++ box/trunk/bin/bbstored/BackupCommands.cpp	2008-05-28 14:37:13 UTC (rev 2179)
@@ -13,20 +13,20 @@
 #include <sstream>
 
 #include "autogen_BackupProtocolServer.h"
+#include "autogen_RaidFileException.h"
 #include "BackupConstants.h"
 #include "BackupContext.h"
-#include "CollectInBufferStream.h"
+#include "BackupStoreConstants.h"
 #include "BackupStoreDirectory.h"
 #include "BackupStoreException.h"
 #include "BackupStoreFile.h"
-#include "StreamableMemBlock.h"
-#include "BackupStoreConstants.h"
-#include "RaidFileController.h"
 #include "BackupStoreInfo.h"
-#include "RaidFileController.h"
+#include "BufferedStream.h"
+#include "CollectInBufferStream.h"
 #include "FileStream.h"
 #include "InvisibleTempFileStream.h"
-#include "BufferedStream.h"
+#include "RaidFileController.h"
+#include "StreamableMemBlock.h"
 
 #include "MemLeakFindOn.h"
 
@@ -181,19 +181,37 @@
 {
 	CHECK_PHASE(Phase_Commands)
 
-	// Ask the context for a directory
-	const BackupStoreDirectory &rdir(rContext.GetDirectory(mObjectID));
-	
 	// Store the listing to a stream
 	std::auto_ptr<CollectInBufferStream> stream(new CollectInBufferStream);
-	rdir.WriteToStream(*stream, mFlagsMustBeSet, mFlagsNotToBeSet, mSendAttributes,
-		false /* never send dependency info to the client */);
+
+	try
+	{
+		// Ask the context for a directory
+		const BackupStoreDirectory &rdir(
+			rContext.GetDirectory(mObjectID));
+		rdir.WriteToStream(*stream, mFlagsMustBeSet, 
+			mFlagsNotToBeSet, mSendAttributes,
+			false /* never send dependency info to the client */);
+	}
+	catch (RaidFileException &e)
+	{
+		if (e.GetSubType() == RaidFileException::RaidFileDoesntExist)
+		{
+			return std::auto_ptr<ProtocolObject>(
+				new BackupProtocolServerError(
+					BackupProtocolServerError::ErrorType,
+					BackupProtocolServerError::Err_DoesNotExist));
+		}
+		throw;
+	}
+
 	stream->SetForReading();
 	
 	// Get the protocol to send the stream
 	rProtocol.SendStreamAfterCommand(stream.release());
 
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));
+	return std::auto_ptr<ProtocolObject>(
+		new BackupProtocolServerSuccess(mObjectID));
 }
 
 // --------------------------------------------------------------------------




More information about the Boxbackup-commit mailing list