From 6779d3cb4ffcc9fa7d860a6f4abaa5bed009098c Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 9 Feb 2007 22:30:15 +0000 Subject: Catch errors during restore (refs #3) --- lib/backupclient/BackupClientRestore.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'lib/backupclient') diff --git a/lib/backupclient/BackupClientRestore.cpp b/lib/backupclient/BackupClientRestore.cpp index b752b6a2..65ee377c 100644 --- a/lib/backupclient/BackupClientRestore.cpp +++ b/lib/backupclient/BackupClientRestore.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "BackupClientRestore.h" #include "autogen_BackupProtocolClient.h" @@ -225,9 +226,36 @@ static void BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Di // 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. + + 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; + } - // Create the local directory (if not already done) -- path and owner set later, just use restrictive owner mode - switch(ObjectExists(rLocalDirectoryName.c_str())) + switch(exists) { case ObjectExists_Dir: // Do nothing -- cgit v1.2.3