summaryrefslogtreecommitdiff
path: root/bin/bbstored/BackupContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bin/bbstored/BackupContext.cpp')
-rw-r--r--bin/bbstored/BackupContext.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/bin/bbstored/BackupContext.cpp b/bin/bbstored/BackupContext.cpp
index c796c13a..cd17812c 100644
--- a/bin/bbstored/BackupContext.cpp
+++ b/bin/bbstored/BackupContext.cpp
@@ -132,6 +132,7 @@ bool BackupContext::AttemptToGetWriteLock()
// Request the lock
bool gotLock = mWriteLock.TryAndGetLock(writeLockFile.c_str(), 0600 /* restrictive file permissions */);
+#ifndef WIN32
if(!gotLock)
{
// The housekeeping process might have the thing open -- ask it to stop
@@ -150,6 +151,7 @@ bool BackupContext::AttemptToGetWriteLock()
} while(!gotLock && tries > 0);
}
+#endif
if(gotLock)
{
@@ -453,13 +455,21 @@ int64_t BackupContext::AddFile(IOStream &rFile, int64_t InDirectory, int64_t Mod
try
{
// Open it twice
+#ifdef WIN32
+ FileStream diff(tempFn.c_str(),
+ O_RDWR | O_CREAT | O_BINARY);
+ FileStream diff2(tempFn.c_str(),
+ O_RDWR | O_BINARY);
+#else
FileStream diff(tempFn.c_str(), O_RDWR | O_CREAT | O_EXCL);
FileStream diff2(tempFn.c_str(), O_RDONLY);
- // Unlink it immediately, so it definately goes away
+
+ // 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
if(!rFile.CopyStreamTo(diff, BACKUP_STORE_TIMEOUT))
@@ -508,6 +518,14 @@ int64_t BackupContext::AddFile(IOStream &rFile, int64_t InDirectory, int64_t Mod
::unlink(tempFn.c_str());
throw;
}
+
+#ifdef WIN32
+ // we can't delete the file while it's open, above
+ if(::unlink(tempFn.c_str()) != 0)
+ {
+ THROW_EXCEPTION(CommonException, OSFileError);
+ }
+#endif
}
// Get the blocks used