From b10668519f0f17e40ce71ade4a34f83c0329978d Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 8 Nov 2012 00:35:06 +0000 Subject: Make CreateForRegeneration save the AccountEnabled flag and any extra data copied from the original info file. --- lib/backupstore/BackupStoreCheck2.cpp | 13 ++++++++++++- lib/backupstore/BackupStoreInfo.cpp | 9 +++++++-- lib/backupstore/BackupStoreInfo.h | 9 +++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) (limited to 'lib/backupstore') diff --git a/lib/backupstore/BackupStoreCheck2.cpp b/lib/backupstore/BackupStoreCheck2.cpp index ae5179ed..72ac9480 100644 --- a/lib/backupstore/BackupStoreCheck2.cpp +++ b/lib/backupstore/BackupStoreCheck2.cpp @@ -646,6 +646,15 @@ void BackupStoreCheck::WriteNewStoreInfo() } // Build a new store info + std::auto_ptr extra_data; + if(pOldInfo.get()) + { + extra_data.reset(new MemBlockStream(pOldInfo->GetExtraData())); + } + else + { + extra_data.reset(new MemBlockStream(/* empty */)); + } std::auto_ptr info(BackupStoreInfo::CreateForRegeneration( mAccountID, mAccountName, @@ -658,7 +667,9 @@ void BackupStoreCheck::WriteNewStoreInfo() mBlocksInDeletedFiles, mBlocksInDirectories, softLimit, - hardLimit)); + hardLimit, + (pOldInfo.get() ? pOldInfo->IsAccountEnabled() : true), + *extra_data)); info->AdjustNumFiles(mNumFiles); info->AdjustNumOldFiles(mNumOldFiles); info->AdjustNumDeletedFiles(mNumDeletedFiles); diff --git a/lib/backupstore/BackupStoreInfo.cpp b/lib/backupstore/BackupStoreInfo.cpp index 8fbf591d..e9f0e16b 100644 --- a/lib/backupstore/BackupStoreInfo.cpp +++ b/lib/backupstore/BackupStoreInfo.cpp @@ -284,7 +284,8 @@ std::auto_ptr BackupStoreInfo::CreateForRegeneration( int64_t LastObjectID, int64_t BlocksUsed, int64_t BlocksInCurrentFiles, int64_t BlocksInOldFiles, int64_t BlocksInDeletedFiles, int64_t BlocksInDirectories, - int64_t BlockSoftLimit, int64_t BlockHardLimit) + int64_t BlockSoftLimit, int64_t BlockHardLimit, + bool AccountEnabled, IOStream& ExtraData) { // Generate the filename std::string fn(rRootDir + INFO_FILENAME); @@ -298,7 +299,7 @@ std::auto_ptr BackupStoreInfo::CreateForRegeneration( info->mDiscSet = DiscSet; info->mFilename = fn; info->mReadOnly = false; - + // Insert info starting info info->mClientStoreMarker = 0; info->mLastObjectIDUsed = LastObjectID; @@ -309,7 +310,11 @@ std::auto_ptr BackupStoreInfo::CreateForRegeneration( info->mBlocksInDirectories = BlocksInDirectories; info->mBlocksSoftLimit = BlockSoftLimit; info->mBlocksHardLimit = BlockHardLimit; + info->mAccountEnabled = AccountEnabled; + ExtraData.CopyStreamTo(info->mExtraData); + info->mExtraData.SetForReading(); + // return it to caller return info; } diff --git a/lib/backupstore/BackupStoreInfo.h b/lib/backupstore/BackupStoreInfo.h index 58a00cc1..752cc44a 100644 --- a/lib/backupstore/BackupStoreInfo.h +++ b/lib/backupstore/BackupStoreInfo.h @@ -139,15 +139,20 @@ public: const CollectInBufferStream& GetExtraData() const { return mExtraData; } void SetAccountEnabled(bool IsEnabled) {mAccountEnabled = IsEnabled; } -private: + /** + * @return a new BackupStoreInfo with the requested properties. + * This is exposed to allow testing, do not use otherwise! + */ static std::auto_ptr CreateForRegeneration( int32_t AccountID, const std::string &rAccountName, const std::string &rRootDir, int DiscSet, int64_t LastObjectID, int64_t BlocksUsed, int64_t BlocksInCurrentFiles, int64_t BlocksInOldFiles, int64_t BlocksInDeletedFiles, int64_t BlocksInDirectories, - int64_t BlockSoftLimit, int64_t BlockHardLimit); + int64_t BlockSoftLimit, int64_t BlockHardLimit, + bool AccountEnabled, IOStream& ExtraData); +private: // Location information // Be VERY careful about changing types of these values, as // they now define the sizes of fields on disk (via Archive). -- cgit v1.2.3