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

Ben Summers boxbackup-dev@fluffy.co.uk
Thu, 15 Dec 2005 10:43:28 +0000


I don't this is quite right.

The name of error is wrong. Why would the client care about RaidFiles  
anyway? Surely the error should be "directory doesn't exist".

In which case, checking for a RaidFile exception isn't quite right,  
because you're missing the case where the object ID refers to a file.

Also, brace placement is against style guide.

What problem are you attempting to solve here?

Ben



On 15 Dec 2005, at 00:40, subversion@fluffy.co.uk wrote:

> 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
>
> _______________________________________________
> Boxbackup-dev mailing list
> Boxbackup-dev@fluffy.co.uk
> http://lists.warhead.org.uk/mailman/listinfo/boxbackup-dev