[Box Backup-dev] COMMIT r235 - box/chris/boxi/bin/bbstored

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Thu Dec 15 00:40:37 GMT 2005


Author: chris
Date: 2005-12-15 00:40:32 +0000 (Thu, 15 Dec 2005)
New Revision: 235

Modified:
   box/chris/boxi/bin/bbstored/BackupCommands.cpp
   box/chris/boxi/bin/bbstored/backupprotocol.txt
Log:
* BackupCommands.cpp
- Catch RaidFileExceptions and send an appropriate error back to the client,
  rather than aborting the connection


Modified: box/chris/boxi/bin/bbstored/BackupCommands.cpp
===================================================================
--- box/chris/boxi/bin/bbstored/BackupCommands.cpp	2005-12-15 00:17:22 UTC (rev 234)
+++ box/chris/boxi/bin/bbstored/BackupCommands.cpp	2005-12-15 00:40:32 UTC (rev 235)
@@ -12,6 +12,7 @@
 #include <syslog.h>
 
 #include "autogen_BackupProtocolServer.h"
+#include "autogen_RaidFileException.h"
 #include "BackupConstants.h"
 #include "BackupContext.h"
 #include "CollectInBufferStream.h"
@@ -156,18 +157,31 @@
 	CHECK_PHASE(Phase_Commands)
 
 	// Ask the context for a directory
-	const BackupStoreDirectory &rdir(rContext.GetDirectory(mObjectID));
+	try {
+		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 */);
-	stream->SetForReading();
+		// 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 */);
+		stream->SetForReading();
 	
-	// Get the protocol to send the stream
-	rProtocol.SendStreamAfterCommand(stream.release());
+		// 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));
+	} catch (RaidFileException &e) {
+		return std::auto_ptr<ProtocolObject>(
+			new BackupProtocolServerError(
+				BackupProtocolServerError::ErrorType, 
+				BackupProtocolServerError::Err_RaidFileDoesntExist
+				)
+			);
+	}
 }
 
 // --------------------------------------------------------------------------

Modified: box/chris/boxi/bin/bbstored/backupprotocol.txt
===================================================================
--- box/chris/boxi/bin/bbstored/backupprotocol.txt	2005-12-15 00:17:22 UTC (rev 234)
+++ box/chris/boxi/bin/bbstored/backupprotocol.txt	2005-12-15 00:40:32 UTC (rev 235)
@@ -39,6 +39,7 @@
 	CONSTANT	Err_DiffFromFileDoesNotExist	12
 	CONSTANT	Err_DoesNotExistInDirectory		13
 	CONSTANT	Err_PatchConsistencyError		14
+	CONSTANT	Err_RaidFileDoesntExist		15
 
 Version		1	Command(Version)	Reply
 	int32	Version




More information about the Boxbackup-dev mailing list