[Box Backup-commit] COMMIT r1801 - box/chris/merge/bin/bbackupd

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Sat Sep 1 14:26:31 BST 2007


Author: chris
Date: 2007-09-01 14:26:31 +0100 (Sat, 01 Sep 2007)
New Revision: 1801

Modified:
   box/chris/merge/bin/bbackupd/BackupClientDirectoryRecord.cpp
   box/chris/merge/bin/bbackupd/BackupClientDirectoryRecord.h
   box/chris/merge/bin/bbackupd/BackupDaemon.h
Log:
Log more detailed errors when the server returns an error while uploading
a file. (merges [1781])


Modified: box/chris/merge/bin/bbackupd/BackupClientDirectoryRecord.cpp
===================================================================
--- box/chris/merge/bin/bbackupd/BackupClientDirectoryRecord.cpp	2007-09-01 13:13:19 UTC (rev 1800)
+++ box/chris/merge/bin/bbackupd/BackupClientDirectoryRecord.cpp	2007-09-01 13:26:31 UTC (rev 1801)
@@ -887,9 +887,7 @@
 				{
 					// Connection errors should just be passed on to the main handler, retries
 					// would probably just cause more problems.
-					rParams.GetProgressNotifier()
-						.NotifyFileUploadException(
-							this, filename, e);
+					// Already logged by UploadFile
 					throw;
 				}
 				catch(BoxException &e)
@@ -1386,12 +1384,17 @@
 		{
 			// Check and see what error the protocol has -- as it might be an error...
 			int type, subtype;
-			if(connection.GetLastError(type, subtype)
-				&& type == BackupProtocolClientError::ErrorType
+			if(connection.GetLastError(type, subtype))
+			{
+				if(type == BackupProtocolClientError::ErrorType
 				&& subtype == BackupProtocolClientError::Err_StorageLimitExceeded)
-			{
-				// The hard limit was exceeded on the server, notify!
-				rParams.mrDaemon.NotifySysadmin(BackupDaemon::NotifyEvent_StoreFull);
+				{
+					// The hard limit was exceeded on the server, notify!
+					rParams.mrDaemon.NotifySysadmin(BackupDaemon::NotifyEvent_StoreFull);
+				}
+				rParams.GetProgressNotifier()
+					.NotifyFileUploadServerError(
+						this, rFilename, type, subtype);
 			}
 		}
 		

Modified: box/chris/merge/bin/bbackupd/BackupClientDirectoryRecord.h
===================================================================
--- box/chris/merge/bin/bbackupd/BackupClientDirectoryRecord.h	2007-09-01 13:13:19 UTC (rev 1800)
+++ box/chris/merge/bin/bbackupd/BackupClientDirectoryRecord.h	2007-09-01 13:26:31 UTC (rev 1801)
@@ -78,6 +78,10 @@
 		const BackupClientDirectoryRecord* pDirRecord,
 		const std::string& rLocalPath,
 		const BoxException& rException) = 0;
+	virtual void NotifyFileUploadServerError(
+		const BackupClientDirectoryRecord* pDirRecord,
+		const std::string& rLocalPath,
+		int type, int subtype) = 0;
 	virtual void NotifyFileUploading(
 		const BackupClientDirectoryRecord* pDirRecord,
 		const std::string& rLocalPath) = 0;

Modified: box/chris/merge/bin/bbackupd/BackupDaemon.h
===================================================================
--- box/chris/merge/bin/bbackupd/BackupDaemon.h	2007-09-01 13:13:19 UTC (rev 1800)
+++ box/chris/merge/bin/bbackupd/BackupDaemon.h	2007-09-01 13:26:31 UTC (rev 1801)
@@ -21,6 +21,7 @@
 #include "SocketListen.h"
 #include "SocketStream.h"
 #include "Logging.h"
+#include "autogen_BackupProtocolClient.h"
 
 #ifdef WIN32
 	#include "WinNamedPipeStream.h"
@@ -304,6 +305,70 @@
 				<< "/"  << rException.GetSubType() << ")");
 		}
  	}
+  	virtual void NotifyFileUploadServerError(
+ 		const BackupClientDirectoryRecord* pDirRecord,
+ 		const std::string& rLocalPath,
+ 		int type, int subtype)
+ 	{
+		std::ostringstream msgs;
+		if (type != BackupProtocolClientError::ErrorType)
+		{
+			msgs << "unknown error type " << type;
+		}
+		else
+		{
+			switch(subtype)
+			{
+			case BackupProtocolClientError::Err_WrongVersion:
+				msgs << "WrongVersion";
+				break;
+			case BackupProtocolClientError::Err_NotInRightProtocolPhase:
+				msgs << "NotInRightProtocolPhase";
+				break;
+			case BackupProtocolClientError::Err_BadLogin:
+				msgs << "BadLogin";
+				break;
+			case BackupProtocolClientError::Err_CannotLockStoreForWriting:
+				msgs << "CannotLockStoreForWriting";
+				break;
+			case BackupProtocolClientError::Err_SessionReadOnly:
+				msgs << "SessionReadOnly";
+				break;
+			case BackupProtocolClientError::Err_FileDoesNotVerify:
+				msgs << "FileDoesNotVerify";
+				break;
+			case BackupProtocolClientError::Err_DoesNotExist:
+				msgs << "DoesNotExist";
+				break;
+			case BackupProtocolClientError::Err_DirectoryAlreadyExists:
+				msgs << "DirectoryAlreadyExists";
+				break;
+			case BackupProtocolClientError::Err_CannotDeleteRoot:
+				msgs << "CannotDeleteRoot";
+				break;
+			case BackupProtocolClientError::Err_TargetNameExists:
+				msgs << "TargetNameExists";
+				break;
+			case BackupProtocolClientError::Err_StorageLimitExceeded:
+				msgs << "StorageLimitExceeded";
+				break;
+			case BackupProtocolClientError::Err_DiffFromFileDoesNotExist:
+				msgs << "DiffFromFileDoesNotExist";
+				break;
+			case BackupProtocolClientError::Err_DoesNotExistInDirectory:
+				msgs << "DoesNotExistInDirectory";
+				break;
+			case BackupProtocolClientError::Err_PatchConsistencyError:
+				msgs << "PatchConsistencyError";
+				break;
+			default:
+				msgs << "unknown error subtype " << subtype;
+			}
+		}
+
+		BOX_ERROR("Failed to upload file: " << rLocalPath 
+			<< ": server error: " << msgs.str());
+ 	}
  	virtual void NotifyFileUploading(
  		const BackupClientDirectoryRecord* pDirRecord,
  		const std::string& rLocalPath) 




More information about the Boxbackup-commit mailing list