From 719ed242a8962591b4798fba9e4797ef27626e49 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 4 Nov 2007 16:34:41 +0000 Subject: Really fix unlink() during restore, fixes [1919]. --- lib/backupclient/BackupClientRestore.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/backupclient') diff --git a/lib/backupclient/BackupClientRestore.cpp b/lib/backupclient/BackupClientRestore.cpp index 58234562..b5a54964 100644 --- a/lib/backupclient/BackupClientRestore.cpp +++ b/lib/backupclient/BackupClientRestore.cpp @@ -453,8 +453,11 @@ static int BackupClientRestoreDir(BackupProtocolClient &rConnection, int64_t Dir BackupStoreFilenameClear nm(en->GetName()); std::string localFilename(rLocalDirectoryName + DIRECTORY_SEPARATOR_ASCHAR + nm.GetClearFilename()); - // Unlink anything which already exists -- for resuming restores, we can't overwrite files already there. - if(::unlink(localFilename.c_str()) != 0) + // Unlink anything which already exists: + // For resuming restores, we can't overwrite + // files already there. + if(ObjectExists(localFilename) != ObjectExists_NoObject && + ::unlink(localFilename.c_str()) != 0) { BOX_ERROR("Failed to delete file '" << localFilename << "': " << -- cgit v1.2.3