diff options
author | Chris Wilson <chris+github@qwirx.com> | 2008-03-28 22:18:44 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2008-03-28 22:18:44 +0000 |
commit | 4fca88ed02c1f0b5208abf2420f73023de54c23e (patch) | |
tree | 51e882893d283f05b569bd27f7efab7b041c4548 /lib/backupclient | |
parent | 74bfdebe02405f7847fded96e42c1ccd297c9b9f (diff) |
Improve logging with macros that consistently output strerror(errno) and
errno, replacing almost all use of strerror() in the main code.
Log a more detailed error message before throwing an exception for some
more system call failures.
Make FileStream store its filename on all platforms, not just Windows.
Wrap some long lines at less than 80 characters to improve readability.
Fix some minor violations of coding standard (white space) and a typo
in a comment.
Diffstat (limited to 'lib/backupclient')
-rw-r--r-- | lib/backupclient/BackupClientRestore.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/backupclient/BackupClientRestore.cpp b/lib/backupclient/BackupClientRestore.cpp index b5a54964..aab514ad 100644 --- a/lib/backupclient/BackupClientRestore.cpp +++ b/lib/backupclient/BackupClientRestore.cpp @@ -267,14 +267,14 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir "restore this object."); if(::unlink(rLocalDirectoryName.c_str()) != 0) { - BOX_ERROR("Failed to delete file " << - rLocalDirectoryName << ": " << - strerror(errno)); + BOX_LOG_SYS_ERROR("Failed to delete " + "file '" << + rLocalDirectoryName << "'"); return Restore_UnknownError; } BOX_TRACE("In restore, directory name " - "collision with file " << - rLocalDirectoryName); + "collision with file '" << + rLocalDirectoryName << "'"); } break; case ObjectExists_NoObject: @@ -378,9 +378,8 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir exists == ObjectExists_File) && ::mkdir(rLocalDirectoryName.c_str(), S_IRWXU) != 0) { - BOX_ERROR("Failed to create directory '" << - rLocalDirectoryName << "': " << - strerror(errno)); + BOX_LOG_SYS_ERROR("Failed to create directory '" << + rLocalDirectoryName << "'"); return Restore_UnknownError; } @@ -451,7 +450,9 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir { // Local name BackupStoreFilenameClear nm(en->GetName()); - std::string localFilename(rLocalDirectoryName + DIRECTORY_SEPARATOR_ASCHAR + nm.GetClearFilename()); + std::string localFilename(rLocalDirectoryName + + DIRECTORY_SEPARATOR_ASCHAR + + nm.GetClearFilename()); // Unlink anything which already exists: // For resuming restores, we can't overwrite @@ -459,20 +460,23 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir if(ObjectExists(localFilename) != ObjectExists_NoObject && ::unlink(localFilename.c_str()) != 0) { - BOX_ERROR("Failed to delete file '" << - localFilename << "': " << - strerror(errno)); + BOX_LOG_SYS_ERROR("Failed to delete " + "file '" << localFilename << + "'"); return Restore_UnknownError; } // Request it from the store - rConnection.QueryGetFile(DirectoryID, en->GetObjectID()); + rConnection.QueryGetFile(DirectoryID, + en->GetObjectID()); // Stream containing encoded file - std::auto_ptr<IOStream> objectStream(rConnection.ReceiveStream()); + std::auto_ptr<IOStream> objectStream( + rConnection.ReceiveStream()); - // Decode the file -- need to do different things depending on whether - // the directory entry has additional attributes + // Decode the file -- need to do different + // things depending on whether the directory + // entry has additional attributes try { if(en->HasAttributes()) |