diff options
Diffstat (limited to 'bin/bbstored/BackupContext.cpp')
-rw-r--r-- | bin/bbstored/BackupContext.cpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/bin/bbstored/BackupContext.cpp b/bin/bbstored/BackupContext.cpp index a3f614a5..16388099 100644 --- a/bin/bbstored/BackupContext.cpp +++ b/bin/bbstored/BackupContext.cpp @@ -24,6 +24,8 @@ #include "BackupStoreDaemon.h" #include "RaidFileController.h" #include "FileStream.h" +#include "InvisibleTempFileStream.h" +#include "BufferedStream.h" #include "MemLeakFindOn.h" @@ -125,7 +127,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); @@ -151,7 +152,7 @@ bool BackupContext::AttemptToGetWriteLock() } while(!gotLock && tries > 0); } - + if(gotLock) { // Got the lock, mark as not read only @@ -159,10 +160,6 @@ bool BackupContext::AttemptToGetWriteLock() } return gotLock; -#else // WIN32 - // no housekeeping process, we do have the lock - return true; -#endif // !WIN32 } @@ -310,7 +307,8 @@ BackupStoreDirectory &BackupContext::GetDirectoryInternal(int64_t ObjectID) std::auto_ptr<BackupStoreDirectory> dir(new BackupStoreDirectory); // Read it from the stream, then set it's revision ID - dir->ReadFromStream(*objectFile, IOStream::TimeOutInfinite); + BufferedStream buf(*objectFile); + dir->ReadFromStream(buf, IOStream::TimeOutInfinite); dir->SetRevisionID(revID); // Make sure the size of the directory is available for writing the dir back @@ -459,9 +457,9 @@ int64_t BackupContext::AddFile(IOStream &rFile, int64_t InDirectory, int64_t Mod { // Open it twice #ifdef WIN32 - FileStream diff(tempFn.c_str(), + InvisibleTempFileStream diff(tempFn.c_str(), O_RDWR | O_CREAT | O_BINARY); - FileStream diff2(tempFn.c_str(), + InvisibleTempFileStream diff2(tempFn.c_str(), O_RDWR | O_BINARY); #else FileStream diff(tempFn.c_str(), O_RDWR | O_CREAT | O_EXCL); @@ -521,14 +519,6 @@ 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 |