summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2006-08-31 20:08:11 +0000
committerChris Wilson <chris+github@qwirx.com>2006-08-31 20:08:11 +0000
commitb97df587f4ebf1cd445d72d9f129a24bb8d29b67 (patch)
treed4f3927c223b767a7a676dae6ad2fbf7a34ad242
parent94212acf332d56413ae0dc2a6c9c9fccb02f6bee (diff)
* bin/bbstored/BackupContext.cpp
- Delete the temporary file on Win32 just like on other platforms (note that this reduces the guarantees that the file will be deleted, especially if an exception is thrown, refs #819)
-rw-r--r--bin/bbstored/BackupContext.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/bin/bbstored/BackupContext.cpp b/bin/bbstored/BackupContext.cpp
index a3f614a5..d78ed9b1 100644
--- a/bin/bbstored/BackupContext.cpp
+++ b/bin/bbstored/BackupContext.cpp
@@ -125,7 +125,6 @@ void BackupContext::ReceivedFinishCommand()
// --------------------------------------------------------------------------
bool BackupContext::AttemptToGetWriteLock()
{
-#ifndef WIN32
// Make the filename of the write lock file
std::string writeLockFile;
StoreStructure::MakeWriteLockFilename(mStoreRoot, mStoreDiscSet, writeLockFile);
@@ -159,10 +158,6 @@ bool BackupContext::AttemptToGetWriteLock()
}
return gotLock;
-#else // WIN32
- // no housekeeping process, we do have the lock
- return true;
-#endif // !WIN32
}
@@ -466,12 +461,6 @@ int64_t BackupContext::AddFile(IOStream &rFile, int64_t InDirectory, int64_t Mod
#else
FileStream diff(tempFn.c_str(), O_RDWR | O_CREAT | O_EXCL);
FileStream diff2(tempFn.c_str(), O_RDONLY);
-
- // Unlink it immediately, so it definitely goes away
- if(::unlink(tempFn.c_str()) != 0)
- {
- THROW_EXCEPTION(CommonException, OSFileError);
- }
#endif
// Stream the incoming diff to this temporary file
@@ -514,6 +503,14 @@ int64_t BackupContext::AddFile(IOStream &rFile, int64_t InDirectory, int64_t Mod
spaceAdjustFromDiff = from->GetDiscUsageInBlocks() - oldVersionNewBlocksUsed;
// Everything cleans up here...
+ diff.Close();
+ diff2.Close();
+
+ // Unlink the temporary file
+ if(::unlink(tempFn.c_str()) != 0)
+ {
+ THROW_EXCEPTION(CommonException, OSFileError);
+ }
}
catch(...)
{