[Box Backup-dev] COMMIT r596 - box/chris/general/bin/bbstored
boxbackup-dev at fluffy.co.uk
boxbackup-dev at fluffy.co.uk
Sat May 27 10:57:01 BST 2006
Author: chris
Date: 2006-05-27 09:56:46 +0000 (Sat, 27 May 2006)
New Revision: 596
Modified:
box/chris/general/bin/bbstored/BackupContext.cpp
Log:
* BackupContext.cpp
- Disabled interprocess comms on Win32
- Don't try to open a read-only second handle on Win32, this would fail
because openfile() only allows other readers, not writers (maybe fix
openfile() instead?)
- Don't unlink file while it's still open, but just after closing it
Modified: box/chris/general/bin/bbstored/BackupContext.cpp
===================================================================
--- box/chris/general/bin/bbstored/BackupContext.cpp 2006-05-27 09:54:37 UTC (rev 595)
+++ box/chris/general/bin/bbstored/BackupContext.cpp 2006-05-27 09:56:46 UTC (rev 596)
@@ -132,6 +132,7 @@
// 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 @@
} while(!gotLock && tries > 0);
}
+#endif
if(gotLock)
{
@@ -453,13 +455,19 @@
try
{
// Open it twice
+#ifdef WIN32
+ FileStream diff(tempFn.c_str(), O_RDWR | O_CREAT);
+ FileStream diff2(tempFn.c_str(), O_RDWR);
+#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
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,8 +516,16 @@
::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
blocksUsed = storeFile.GetDiscUsageInBlocks();
More information about the Boxbackup-dev
mailing list