[Box Backup-commit] COMMIT r1272 - box/chris/merge/lib/backupclient

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Fri, 09 Feb 2007 22:30:16 +0000


Author: chris
Date: 2007-02-09 22:30:15 +0000 (Fri, 09 Feb 2007)
New Revision: 1272

Modified:
   box/chris/merge/lib/backupclient/BackupClientRestore.cpp
Log:
Catch errors during restore (refs #3)


Modified: box/chris/merge/lib/backupclient/BackupClientRestore.cpp
===================================================================
--- box/chris/merge/lib/backupclient/BackupClientRestore.cpp	2007-02-08 21:57:17 UTC (rev 1271)
+++ box/chris/merge/lib/backupclient/BackupClientRestore.cpp	2007-02-09 22:30:15 UTC (rev 1272)
@@ -19,6 +19,7 @@
 #include <set>
 #include <limits.h>
 #include <stdio.h>
+#include <errno.h>
 
 #include "BackupClientRestore.h"
 #include "autogen_BackupProtocolClient.h"
@@ -225,10 +226,37 @@
 	
 	// Save the resumption information
 	Params.mResumeInfo.Save(Params.mRestoreResumeInfoFilename);
+	
+	// Create the local directory, if not already done.
+	// Path and owner set later, just use restrictive owner mode.
 
-	// Create the local directory (if not already done) -- path and owner set later, just use restrictive owner mode
-	switch(ObjectExists(rLocalDirectoryName.c_str()))
+	int exists;
+
+	try
 	{
+		exists = ObjectExists(rLocalDirectoryName.c_str());
+	}
+	catch (BoxException &e)
+	{
+		::syslog(LOG_ERR, "Failed to check existence for %s: %s", 
+			rLocalDirectoryName.c_str(), e.what());
+		return Restore_UnknownError;
+	}
+	catch(std::exception &e)
+	{
+		::syslog(LOG_ERR, "Failed to check existence for %s: %s", 
+			rLocalDirectoryName.c_str(), e.what());
+		return Restore_UnknownError;
+	}
+	catch(...)
+	{
+		::syslog(LOG_ERR, "Failed to check existence for %s: "
+			"unknown error", rLocalDirectoryName.c_str());
+		return Restore_UnknownError;
+	}
+
+	switch(exists)
+	{
 		case ObjectExists_Dir:
 			// Do nothing
 			break;