diff options
Diffstat (limited to 'lib/backupstore/BackupStoreInfo.cpp')
-rw-r--r-- | lib/backupstore/BackupStoreInfo.cpp | 267 |
1 files changed, 0 insertions, 267 deletions
diff --git a/lib/backupstore/BackupStoreInfo.cpp b/lib/backupstore/BackupStoreInfo.cpp index c58ae99a..b6714709 100644 --- a/lib/backupstore/BackupStoreInfo.cpp +++ b/lib/backupstore/BackupStoreInfo.cpp @@ -11,10 +11,7 @@ #include <algorithm> -<<<<<<< HEAD -======= #include "Archive.h" ->>>>>>> 0.12 #include "BackupStoreInfo.h" #include "BackupStoreException.h" #include "RaidFileWrite.h" @@ -22,57 +19,12 @@ #include "MemLeakFindOn.h" -<<<<<<< HEAD -// set packing to one byte -#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS -#include "BeginStructPackForWire.h" -#else -BEGIN_STRUCTURE_PACKING_FOR_WIRE -#endif - -// ****************** -// make sure the defaults in CreateNew are modified! -// ****************** -typedef struct -{ - int32_t mMagicValue; // also the version number - int32_t mAccountID; - int64_t mClientStoreMarker; - int64_t mLastObjectIDUsed; - int64_t mBlocksUsed; - int64_t mBlocksInOldFiles; - int64_t mBlocksInDeletedFiles; - int64_t mBlocksInDirectories; - int64_t mBlocksSoftLimit; - int64_t mBlocksHardLimit; - uint32_t mCurrentMarkNumber; - uint32_t mOptionsPresent; // bit mask of optional elements present - int64_t mNumberDeletedDirectories; - // Then loads of int64_t IDs for the deleted directories -} info_StreamFormat; - -#define INFO_MAGIC_VALUE 0x34832476 - -// Use default packing -#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS -#include "EndStructPackForWire.h" -#else -END_STRUCTURE_PACKING_FOR_WIRE -#endif - -======= ->>>>>>> 0.12 #ifdef BOX_RELEASE_BUILD #define NUM_DELETED_DIRS_BLOCK 256 #else #define NUM_DELETED_DIRS_BLOCK 2 #endif -<<<<<<< HEAD -#define INFO_FILENAME "info" - -======= ->>>>>>> 0.12 // -------------------------------------------------------------------------- // // Function @@ -89,10 +41,6 @@ BackupStoreInfo::BackupStoreInfo() mClientStoreMarker(0), mLastObjectIDUsed(-1), mBlocksUsed(0), -<<<<<<< HEAD - mBlocksInOldFiles(0), - mBlocksInDeletedFiles(0) -======= mBlocksInCurrentFiles(0), mBlocksInOldFiles(0), mBlocksInDeletedFiles(0), @@ -102,7 +50,6 @@ BackupStoreInfo::BackupStoreInfo() mNumDeletedFiles(0), mNumDirectories(0), mAccountEnabled(true) ->>>>>>> 0.12 { } @@ -128,41 +75,6 @@ BackupStoreInfo::~BackupStoreInfo() // -------------------------------------------------------------------------- void BackupStoreInfo::CreateNew(int32_t AccountID, const std::string &rRootDir, int DiscSet, int64_t BlockSoftLimit, int64_t BlockHardLimit) { -<<<<<<< HEAD - // Initial header (is entire file) - info_StreamFormat hdr = { - htonl(INFO_MAGIC_VALUE), // mMagicValue - htonl(AccountID), // mAccountID - 0, // mClientStoreMarker - box_hton64(1), // mLastObjectIDUsed (which is the root directory) - 0, // mBlocksUsed - 0, // mBlocksInOldFiles - 0, // mBlocksInDeletedFiles - 0, // mBlocksInDirectories - box_hton64(BlockSoftLimit), // mBlocksSoftLimit - box_hton64(BlockHardLimit), // mBlocksHardLimit - 0, // mCurrentMarkNumber - 0, // mOptionsPresent - 0 // mNumberDeletedDirectories - }; - - // Generate the filename - ASSERT(rRootDir[rRootDir.size() - 1] == '/' || - rRootDir[rRootDir.size() - 1] == DIRECTORY_SEPARATOR_ASCHAR); - std::string fn(rRootDir + INFO_FILENAME); - - // Open the file for writing - RaidFileWrite rf(DiscSet, fn); - rf.Open(false); // no overwriting, as this is a new file - - // Write header - rf.Write(&hdr, sizeof(hdr)); - - // Commit it to disc, converting it to RAID now - rf.Commit(true); - - // Done. -======= BackupStoreInfo info; info.mAccountID = AccountID; info.mDiscSet = DiscSet; @@ -178,40 +90,11 @@ void BackupStoreInfo::CreateNew(int32_t AccountID, const std::string &rRootDir, info.mExtraData.SetForReading(); // extra data is empty in this case info.Save(false); ->>>>>>> 0.12 } // -------------------------------------------------------------------------- // // Function -<<<<<<< HEAD -// Name: BackupStoreInfo::Load(int32_t, const std::string &, int, bool) -// Purpose: Loads the info from disc, given the root information. Can be marked as read only. -// Created: 2003/08/28 -// -// -------------------------------------------------------------------------- -std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, const std::string &rRootDir, int DiscSet, bool ReadOnly, int64_t *pRevisionID) -{ - // Generate the filename - std::string fn(rRootDir + DIRECTORY_SEPARATOR INFO_FILENAME); - - // Open the file for reading (passing on optional request for revision ID) - std::auto_ptr<RaidFileRead> rf(RaidFileRead::Open(DiscSet, fn, pRevisionID)); - - // Read in a header - info_StreamFormat hdr; - if(!rf->ReadFullBuffer(&hdr, sizeof(hdr), 0 /* not interested in bytes read if this fails */)) - { - THROW_EXCEPTION(BackupStoreException, CouldNotLoadStoreInfo) - } - - // Check it - if(ntohl(hdr.mMagicValue) != INFO_MAGIC_VALUE || (int32_t)ntohl(hdr.mAccountID) != AccountID) - { - THROW_EXCEPTION(BackupStoreException, BadStoreInfoOnLoad) - } - -======= // Name: BackupStoreInfo::Load(int32_t, const std::string &, // int, bool) // Purpose: Loads the info from disc, given the root @@ -255,7 +138,6 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, fn, BackupStoreException, BadStoreInfoOnLoad); } ->>>>>>> 0.12 // Make new object std::auto_ptr<BackupStoreInfo> info(new BackupStoreInfo); @@ -264,23 +146,6 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, info->mDiscSet = DiscSet; info->mFilename = fn; info->mReadOnly = ReadOnly; -<<<<<<< HEAD - - // Insert info from file - info->mClientStoreMarker = box_ntoh64(hdr.mClientStoreMarker); - info->mLastObjectIDUsed = box_ntoh64(hdr.mLastObjectIDUsed); - info->mBlocksUsed = box_ntoh64(hdr.mBlocksUsed); - info->mBlocksInOldFiles = box_ntoh64(hdr.mBlocksInOldFiles); - info->mBlocksInDeletedFiles = box_ntoh64(hdr.mBlocksInDeletedFiles); - info->mBlocksInDirectories = box_ntoh64(hdr.mBlocksInDirectories); - info->mBlocksSoftLimit = box_ntoh64(hdr.mBlocksSoftLimit); - info->mBlocksHardLimit = box_ntoh64(hdr.mBlocksHardLimit); - - // Load up array of deleted objects - int64_t numDelObj = box_ntoh64(hdr.mNumberDeletedDirectories); - - // Then load them in -======= int64_t numDelObj = 0; if (v1) @@ -348,7 +213,6 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, } // Then load the list of deleted directories ->>>>>>> 0.12 if(numDelObj > 0) { int64_t objs[NUM_DELETED_DIRS_BLOCK]; @@ -380,8 +244,6 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, { THROW_EXCEPTION(BackupStoreException, BadStoreInfoOnLoad) } -<<<<<<< HEAD -======= if(v2) { @@ -402,7 +264,6 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, rf->CopyStreamTo(info->mExtraData); } info->mExtraData.SetForReading(); ->>>>>>> 0.12 // return it to caller return info; @@ -417,14 +278,6 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::Load(int32_t AccountID, // Created: 23/4/04 // // -------------------------------------------------------------------------- -<<<<<<< HEAD -std::auto_ptr<BackupStoreInfo> BackupStoreInfo::CreateForRegeneration(int32_t AccountID, const std::string &rRootDir, - int DiscSet, int64_t LastObjectID, int64_t BlocksUsed, int64_t BlocksInOldFiles, - int64_t BlocksInDeletedFiles, int64_t BlocksInDirectories, int64_t BlockSoftLimit, int64_t BlockHardLimit) -{ - // Generate the filename - std::string fn(rRootDir + DIRECTORY_SEPARATOR INFO_FILENAME); -======= std::auto_ptr<BackupStoreInfo> BackupStoreInfo::CreateForRegeneration( int32_t AccountID, const std::string& rAccountName, const std::string &rRootDir, int DiscSet, @@ -436,23 +289,12 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::CreateForRegeneration( { // Generate the filename std::string fn(rRootDir + INFO_FILENAME); ->>>>>>> 0.12 // Make new object std::auto_ptr<BackupStoreInfo> info(new BackupStoreInfo); // Put in basic info info->mAccountID = AccountID; -<<<<<<< HEAD - info->mDiscSet = DiscSet; - info->mFilename = fn; - info->mReadOnly = false; - - // Insert info starting info - info->mClientStoreMarker = 0; - info->mLastObjectIDUsed = LastObjectID; - info->mBlocksUsed = BlocksUsed; -======= info->mAccountName = rAccountName; info->mDiscSet = DiscSet; info->mFilename = fn; @@ -463,21 +305,16 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::CreateForRegeneration( info->mLastObjectIDUsed = LastObjectID; info->mBlocksUsed = BlocksUsed; info->mBlocksInCurrentFiles = BlocksInCurrentFiles; ->>>>>>> 0.12 info->mBlocksInOldFiles = BlocksInOldFiles; info->mBlocksInDeletedFiles = BlocksInDeletedFiles; info->mBlocksInDirectories = BlocksInDirectories; info->mBlocksSoftLimit = BlockSoftLimit; info->mBlocksHardLimit = BlockHardLimit; -<<<<<<< HEAD - -======= info->mAccountEnabled = AccountEnabled; ExtraData.CopyStreamTo(info->mExtraData); info->mExtraData.SetForReading(); ->>>>>>> 0.12 // return it to caller return info; } @@ -486,20 +323,12 @@ std::auto_ptr<BackupStoreInfo> BackupStoreInfo::CreateForRegeneration( // -------------------------------------------------------------------------- // // Function -<<<<<<< HEAD -// Name: BackupStoreInfo::Save() -======= // Name: BackupStoreInfo::Save(bool allowOverwrite) ->>>>>>> 0.12 // Purpose: Save modified info back to disc // Created: 2003/08/28 // // -------------------------------------------------------------------------- -<<<<<<< HEAD -void BackupStoreInfo::Save() -======= void BackupStoreInfo::Save(bool allowOverwrite) ->>>>>>> 0.12 { // Make sure we're initialised (although should never come to this) if(mFilename.empty() || mAccountID == -1 || mDiscSet == -1) @@ -515,29 +344,6 @@ void BackupStoreInfo::Save(bool allowOverwrite) // Then... open a write file RaidFileWrite rf(mDiscSet, mFilename); -<<<<<<< HEAD - rf.Open(true); // allow overwriting - - // Make header - info_StreamFormat hdr; - hdr.mMagicValue = htonl(INFO_MAGIC_VALUE); - hdr.mAccountID = htonl(mAccountID); - hdr.mClientStoreMarker = box_hton64(mClientStoreMarker); - hdr.mLastObjectIDUsed = box_hton64(mLastObjectIDUsed); - hdr.mBlocksUsed = box_hton64(mBlocksUsed); - hdr.mBlocksInOldFiles = box_hton64(mBlocksInOldFiles); - hdr.mBlocksInDeletedFiles = box_hton64(mBlocksInDeletedFiles); - hdr.mBlocksInDirectories = box_hton64(mBlocksInDirectories); - hdr.mBlocksSoftLimit = box_hton64(mBlocksSoftLimit); - hdr.mBlocksHardLimit = box_hton64(mBlocksHardLimit); - hdr.mCurrentMarkNumber = 0; - hdr.mOptionsPresent = 0; - hdr.mNumberDeletedDirectories = box_hton64(mDeletedDirectories.size()); - - // Write header - rf.Write(&hdr, sizeof(hdr)); - -======= rf.Open(allowOverwrite); // Make header @@ -564,7 +370,6 @@ void BackupStoreInfo::Save(bool allowOverwrite) int64_t numDelObj = mDeletedDirectories.size(); archive.Write(numDelObj); ->>>>>>> 0.12 // Write the deleted object list if(mDeletedDirectories.size() > 0) { @@ -592,15 +397,12 @@ void BackupStoreInfo::Save(bool allowOverwrite) tosave -= b; } } -<<<<<<< HEAD -======= archive.Write(mAccountEnabled); mExtraData.Seek(0, IOStream::SeekType_Absolute); mExtraData.CopyStreamTo(rf); mExtraData.Seek(0, IOStream::SeekType_Absolute); ->>>>>>> 0.12 // Commit it to disc, converting it to RAID now rf.Commit(true); @@ -609,9 +411,6 @@ void BackupStoreInfo::Save(bool allowOverwrite) mIsModified = false; } -<<<<<<< HEAD - -======= int BackupStoreInfo::ReportChangesTo(BackupStoreInfo& rOldInfo) { int numChanges = 0; @@ -661,7 +460,6 @@ int BackupStoreInfo::ReportChangesTo(BackupStoreInfo& rOldInfo) \ field += delta; \ mIsModified = true; ->>>>>>> 0.12 // -------------------------------------------------------------------------- // @@ -673,20 +471,6 @@ int BackupStoreInfo::ReportChangesTo(BackupStoreInfo& rOldInfo) // -------------------------------------------------------------------------- void BackupStoreInfo::ChangeBlocksUsed(int64_t Delta) { -<<<<<<< HEAD - if(mReadOnly) - { - THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) - } - if((mBlocksUsed + Delta) < 0) - { - THROW_EXCEPTION(BackupStoreException, StoreInfoBlockDeltaMakesValueNegative) - } - - mBlocksUsed += Delta; - - mIsModified = true; -======= APPLY_DELTA(mBlocksUsed, Delta); } @@ -702,7 +486,6 @@ void BackupStoreInfo::ChangeBlocksUsed(int64_t Delta) void BackupStoreInfo::ChangeBlocksInCurrentFiles(int64_t Delta) { APPLY_DELTA(mBlocksInCurrentFiles, Delta); ->>>>>>> 0.12 } // -------------------------------------------------------------------------- @@ -715,22 +498,7 @@ void BackupStoreInfo::ChangeBlocksInCurrentFiles(int64_t Delta) // -------------------------------------------------------------------------- void BackupStoreInfo::ChangeBlocksInOldFiles(int64_t Delta) { -<<<<<<< HEAD - if(mReadOnly) - { - THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) - } - if((mBlocksInOldFiles + Delta) < 0) - { - THROW_EXCEPTION(BackupStoreException, StoreInfoBlockDeltaMakesValueNegative) - } - - mBlocksInOldFiles += Delta; - - mIsModified = true; -======= APPLY_DELTA(mBlocksInOldFiles, Delta); ->>>>>>> 0.12 } // -------------------------------------------------------------------------- @@ -743,22 +511,7 @@ void BackupStoreInfo::ChangeBlocksInOldFiles(int64_t Delta) // -------------------------------------------------------------------------- void BackupStoreInfo::ChangeBlocksInDeletedFiles(int64_t Delta) { -<<<<<<< HEAD - if(mReadOnly) - { - THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) - } - if((mBlocksInDeletedFiles + Delta) < 0) - { - THROW_EXCEPTION(BackupStoreException, StoreInfoBlockDeltaMakesValueNegative) - } - - mBlocksInDeletedFiles += Delta; - - mIsModified = true; -======= APPLY_DELTA(mBlocksInDeletedFiles, Delta); ->>>>>>> 0.12 } // -------------------------------------------------------------------------- @@ -771,22 +524,6 @@ void BackupStoreInfo::ChangeBlocksInDeletedFiles(int64_t Delta) // -------------------------------------------------------------------------- void BackupStoreInfo::ChangeBlocksInDirectories(int64_t Delta) { -<<<<<<< HEAD - if(mReadOnly) - { - THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) - } - if((mBlocksInDirectories + Delta) < 0) - { - THROW_EXCEPTION(BackupStoreException, StoreInfoBlockDeltaMakesValueNegative) - } - - mBlocksInDirectories += Delta; - - mIsModified = true; -} - -======= APPLY_DELTA(mBlocksInDirectories, Delta); } @@ -809,7 +546,6 @@ void BackupStoreInfo::AdjustNumDirectories(int64_t increase) { APPLY_DELTA(mNumDirectories, increase); } ->>>>>>> 0.12 // -------------------------------------------------------------------------- // @@ -953,8 +689,6 @@ void BackupStoreInfo::SetClientStoreMarker(int64_t ClientStoreMarker) } -<<<<<<< HEAD -======= // -------------------------------------------------------------------------- // // Function @@ -974,5 +708,4 @@ void BackupStoreInfo::SetAccountName(const std::string& rName) mIsModified = true; } ->>>>>>> 0.12 |