Index: src/libchcore/TSQLiteSerializerContainer.cpp =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSQLiteSerializerContainer.cpp (.../TSQLiteSerializerContainer.cpp) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSQLiteSerializerContainer.cpp (.../TSQLiteSerializerContainer.cpp) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -165,7 +165,7 @@ TString strQuery = boost::str(boost::wformat(L"DELETE FROM %1% WHERE id IN (%2%)") % m_strName % strItemsToRemove).c_str(); tStatement.Prepare(strQuery.c_str()); - DBTRACE1_D(_T("Executing query: %s\n"), (PCTSTR)strQuery); + DBTRACE1_D(_T("Executing query: %s\n"), strQuery.c_str()); tStatement.Step(); } } Index: src/libchcore/TSQLiteSerializerRowReader.cpp =================================================================== diff -u -r2fe97a93f21771d75901d4b6559057d1ea055104 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSQLiteSerializerRowReader.cpp (.../TSQLiteSerializerRowReader.cpp) (revision 2fe97a93f21771d75901d4b6559057d1ea055104) +++ src/libchcore/TSQLiteSerializerRowReader.cpp (.../TSQLiteSerializerRowReader.cpp) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -52,7 +52,7 @@ TString strQuery; strQuery = boost::str(boost::wformat(L"SELECT %1% FROM %2% ORDER BY id") % m_rColumns.GetCommaSeparatedColumns().c_str() % m_strContainerName.c_str()).c_str(); - DBTRACE1_D(_T("Executing query: %s\n"), (PCTSTR)strQuery); + DBTRACE1_D(_T("Executing query: %s\n"), strQuery.c_str()); m_spStatement->Prepare(strQuery.c_str()); m_bInitialized = true; } Index: src/libchcore/TSQLiteStatement.cpp =================================================================== diff -u -rc9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSQLiteStatement.cpp (.../TSQLiteStatement.cpp) (revision c9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca) +++ src/libchcore/TSQLiteStatement.cpp (.../TSQLiteStatement.cpp) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -82,7 +82,13 @@ Reset(); return eStep_Finished; default: - THROW_SQLITE_EXCEPTION(eErr_SQLiteStepError, iResult, _T("Cannot perform step on the statement")); + { + const wchar_t* pszErrMsg = (const wchar_t*)sqlite3_errmsg16((sqlite3*)m_spDatabase->GetHandle()); + const size_t stMaxSize = 1024; + wchar_t szText[stMaxSize]; + _snwprintf_s(szText, stMaxSize, _TRUNCATE, L"Cannot perform step on the statement. SQLite reported error: %s", pszErrMsg); + THROW_SQLITE_EXCEPTION(eErr_SQLiteStepError, iResult, szText); + } } } Index: src/libchcore/TSQLiteTaskSchema.cpp =================================================================== diff -u -rd0bc3c187684f54894c7280a936d5507a5e49f35 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSQLiteTaskSchema.cpp (.../TSQLiteTaskSchema.cpp) (revision d0bc3c187684f54894c7280a936d5507a5e49f35) +++ src/libchcore/TSQLiteTaskSchema.cpp (.../TSQLiteTaskSchema.cpp) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -85,7 +85,7 @@ _T("buffer_index INT NOT NULL, current_path varchar(32768) NOT NULL, suboperation_type INT NOT NULL)")); tStatement.Step(); - tStatement.Prepare(_T("CREATE TABLE subtask_copymove(id BIGINT UNIQUE, current_index INT NOT NULL, cf_processed_size BIGINT NOT NULL, is_running boolean NOT NULL, is_initialized boolean NOT NULL, total_size BIGINT NOT NULL, processed_size BIGINT NOT NULL, size_speed varchar(1024) NOT NULL, ") + tStatement.Prepare(_T("CREATE TABLE subtask_copymove(id BIGINT UNIQUE, current_index INT NOT NULL, is_running boolean NOT NULL, is_initialized boolean NOT NULL, total_size BIGINT NOT NULL, processed_size BIGINT NOT NULL, size_speed varchar(1024) NOT NULL, ") _T("total_count BIGINT NOT NULL, processed_count BIGINT NOT NULL, count_speed varchar(1024) NOT NULL, ci_processed_size BIGINT NOT NULL, ci_total_size BIGINT NOT NULL, timer BIGINT NOT NULL, ") _T("buffer_index INT NOT NULL, current_path varchar(32768) NOT NULL, suboperation_type INT NOT NULL)")); tStatement.Step(); Index: src/libchcore/TSubTaskBase.h =================================================================== diff -u -r0b8ae6ab8b538881b651126bf8e6de9c9912a782 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskBase.h (.../TSubTaskBase.h) (revision 0b8ae6ab8b538881b651126bf8e6de9c9912a782) +++ src/libchcore/TSubTaskBase.h (.../TSubTaskBase.h) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -38,14 +38,6 @@ /////////////////////////////////////////////////////////////////////////// // TSubTaskBase -class LIBCHCORE_API TSubTaskProgressInfo -{ -public: - virtual ~TSubTaskProgressInfo() {} - - virtual void ResetProgress() = 0; -}; - class LIBCHCORE_API TSubTaskBase { public: @@ -71,9 +63,6 @@ virtual void Store(const ISerializerPtr& spSerializer) const = 0; virtual void Load(const ISerializerPtr& spSerializer) = 0; - // progress - virtual TSubTaskProgressInfo& GetProgressInfo() = 0; - // stats virtual void GetStatsSnapshot(TSubTaskStatsSnapshotPtr& rStats) const = 0; Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -43,109 +43,6 @@ BEGIN_CHCORE_NAMESPACE -namespace details -{ - /////////////////////////////////////////////////////////////////////////////////////////////////// - // class TCopyMoveProgressInfo - - TCopyMoveProgressInfo::TCopyMoveProgressInfo() : - m_fcCurrentIndex(m_setModifications, 0), - m_ullCurrentFileProcessedSize(m_setModifications, 0) - { - m_setModifications[eMod_Added] = true; - } - - TCopyMoveProgressInfo::~TCopyMoveProgressInfo() - { - } - - void TCopyMoveProgressInfo::ResetProgress() - { - boost::unique_lock lock(m_lock); - m_fcCurrentIndex = 0; - m_ullCurrentFileProcessedSize = 0; - } - - void TCopyMoveProgressInfo::SetCurrentIndex(file_count_t fcIndex) - { - boost::unique_lock lock(m_lock); - m_fcCurrentIndex = fcIndex; - } - - void TCopyMoveProgressInfo::IncreaseCurrentIndex() - { - boost::unique_lock lock(m_lock); - ++m_fcCurrentIndex.Modify(); - } - - file_count_t TCopyMoveProgressInfo::GetCurrentIndex() const - { - boost::shared_lock lock(m_lock); - return m_fcCurrentIndex; - } - - void TCopyMoveProgressInfo::SetCurrentFileProcessedSize(unsigned long long ullSize) - { - boost::unique_lock lock(m_lock); - m_ullCurrentFileProcessedSize = ullSize; - } - - unsigned long long TCopyMoveProgressInfo::GetCurrentFileProcessedSize() const - { - boost::shared_lock lock(m_lock); - return m_ullCurrentFileProcessedSize; - } - - void TCopyMoveProgressInfo::IncreaseCurrentFileProcessedSize(unsigned long long ullSizeToAdd) - { - boost::unique_lock lock(m_lock); - m_ullCurrentFileProcessedSize.Modify() += ullSizeToAdd; - } - - void TCopyMoveProgressInfo::DecreaseCurrentFileProcessedSize(unsigned long long ullSizeToSubtract) - { - boost::unique_lock lock(m_lock); - m_ullCurrentFileProcessedSize.Modify() -= ullSizeToSubtract; - } - - void TCopyMoveProgressInfo::Store(ISerializerRowData& rRowData) const - { - boost::shared_lock lock(m_lock); - if(m_setModifications.any()) - { - if(m_fcCurrentIndex.IsModified()) - rRowData.SetValue(_T("current_index"), m_fcCurrentIndex); - if(m_ullCurrentFileProcessedSize.IsModified()) - rRowData.SetValue(_T("cf_processed_size"), m_ullCurrentFileProcessedSize); - - m_setModifications.reset(); - } - } - - void TCopyMoveProgressInfo::InitColumns(IColumnsDefinition& rColumns) - { - rColumns.AddColumn(_T("id"), ColumnType::value); - rColumns.AddColumn(_T("current_index"), ColumnType::value); - rColumns.AddColumn(_T("cf_processed_size"), ColumnType::value); - } - - void TCopyMoveProgressInfo::Load(const ISerializerRowReaderPtr& spRowReader) - { - boost::unique_lock lock(m_lock); - - spRowReader->GetValue(_T("current_index"), m_fcCurrentIndex.Modify()); - spRowReader->GetValue(_T("cf_processed_size"), m_ullCurrentFileProcessedSize.Modify()); - - m_setModifications.reset(); - } - - bool TCopyMoveProgressInfo::WasSerialized() const - { - boost::shared_lock lock(m_lock); - return !m_setModifications[eMod_Added]; - } -} - // assume max sectors of 4kB (for rounding) #define MAXSECTORSIZE 4096 @@ -171,7 +68,6 @@ void TSubTaskCopyMove::Reset() { - m_tProgressInfo.ResetProgress(); m_tSubTaskStats.Clear(); } @@ -194,8 +90,7 @@ // the stats once - it is being restored in Load() too). if(!m_tSubTaskStats.IsInitialized()) { - m_tSubTaskStats.Init(TBufferSizes::eBuffer_Default, rFilesCache.GetSize(), 0/*rFilesCache.GetSize()*/, - rFilesCache.CalculateTotalSize(), rFilesCache.CalculatePartialSize(m_tProgressInfo.GetCurrentIndex()), TString()); + m_tSubTaskStats.Init(TBufferSizes::eBuffer_Default, rFilesCache.GetSize(), 0, rFilesCache.CalculateTotalSize(), rFilesCache.CalculatePartialSize(m_tSubTaskStats.GetCurrentIndex()), TString()); } // now it's time to check if there is enough space on destination device @@ -218,21 +113,21 @@ AdjustBufferIfNeeded(ccp.dbBuffer, ccp.tBufferSizes); + file_count_t fcIndex = m_tSubTaskStats.GetCurrentIndex(); // log TString strFormat; strFormat = _T("Processing files/folders (ProcessFiles):\r\n\tOnlyCreate: %create\r\n\tFiles/folders count: %filecount\r\n\tIgnore Folders: %ignorefolders\r\n\tDest path: %dstpath\r\n\tCurrent index (0-based): %currindex"); strFormat.Replace(_T("%create"), boost::lexical_cast(ccp.bOnlyCreate).c_str()); strFormat.Replace(_T("%filecount"), boost::lexical_cast(fcSize).c_str()); strFormat.Replace(_T("%ignorefolders"), boost::lexical_cast(bIgnoreFolders).c_str()); strFormat.Replace(_T("%dstpath"), pathDestination.ToString()); - strFormat.Replace(_T("%currindex"), boost::lexical_cast(m_tProgressInfo.GetCurrentIndex()).c_str()); + strFormat.Replace(_T("%currindex"), boost::lexical_cast(fcIndex).c_str()); rLog.logi(strFormat.c_str()); - file_count_t fcIndex = m_tProgressInfo.GetCurrentIndex(); for(; fcIndex < fcSize; fcIndex++) { - m_tProgressInfo.SetCurrentIndex(fcIndex); + m_tSubTaskStats.SetCurrentIndex(fcIndex); // should we kill ? if(rThreadController.KillRequested()) @@ -303,7 +198,7 @@ TLocalFilesystem::SetAttributes(ccp.pathDstFile, spFileInfo->GetAttributes()); // as above } - m_tProgressInfo.SetCurrentIndex(fcIndex); + m_tSubTaskStats.SetCurrentIndex(fcIndex); // new stats m_tSubTaskStats.SetProcessedCount(fcIndex); @@ -444,8 +339,8 @@ else if(bSkip) { // new stats - m_tSubTaskStats.IncreaseProcessedSize(pData->spSrcFile->GetLength64() - m_tProgressInfo.GetCurrentFileProcessedSize()); - m_tSubTaskStats.IncreaseCurrentItemProcessedSize(pData->spSrcFile->GetLength64() - m_tProgressInfo.GetCurrentFileProcessedSize()); + m_tSubTaskStats.IncreaseProcessedSize(pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize()); + m_tSubTaskStats.IncreaseCurrentItemProcessedSize(pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize()); pData->bProcessed = false; return TSubTaskBase::eSubResult_Continue; @@ -474,26 +369,24 @@ else if(bSkip) { // new stats - m_tSubTaskStats.IncreaseProcessedSize(pData->spSrcFile->GetLength64() - m_tProgressInfo.GetCurrentFileProcessedSize()); - m_tSubTaskStats.IncreaseCurrentItemProcessedSize(pData->spSrcFile->GetLength64() - m_tProgressInfo.GetCurrentFileProcessedSize()); + m_tSubTaskStats.IncreaseProcessedSize(pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize()); + m_tSubTaskStats.IncreaseCurrentItemProcessedSize(pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize()); pData->bProcessed = false; return TSubTaskBase::eSubResult_Continue; } listEmptyBuffers.push_back(spBuffer); - // increase count of processed data - m_tProgressInfo.IncreaseCurrentFileProcessedSize(ulWritten); // new stats m_tSubTaskStats.IncreaseProcessedSize(ulWritten); - m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ulWritten); // duplicate of m_tProgressInfo.IncreaseCurrentFileProcessedSize(ulWritten); + m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ulWritten); } } while(!bLastPart); pData->bProcessed = true; - m_tProgressInfo.SetCurrentFileProcessedSize(0); + m_tSubTaskStats.SetCurrentItemProcessedSize(0); return TSubTaskBase::eSubResult_Continue; } @@ -511,7 +404,7 @@ else if(!fileSrc.IsOpen()) { // invalid handle = operation skipped by user - unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tProgressInfo.GetCurrentFileProcessedSize(); + unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize(); m_tSubTaskStats.IncreaseProcessedSize(ullDiff); m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullDiff); @@ -528,10 +421,10 @@ SetFileAttributes(pData->pathDstFile.ToString(), FILE_ATTRIBUTE_NORMAL); // open destination file, handle the failures and possibly existence of the destination file - unsigned long long ullSeekTo = m_tProgressInfo.GetCurrentFileProcessedSize(); + unsigned long long ullSeekTo = m_tSubTaskStats.GetCurrentItemProcessedSize(); bool bDstFileFreshlyCreated = false; - if(m_tProgressInfo.GetCurrentFileProcessedSize() == 0) + if(m_tSubTaskStats.GetCurrentItemProcessedSize() == 0) { // open destination file for case, when we start operation on this file (i.e. it is not resume of the // old operation) @@ -540,7 +433,7 @@ return eResult; else if(!fileDst.IsOpen()) { - unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tProgressInfo.GetCurrentFileProcessedSize(); + unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize(); m_tSubTaskStats.IncreaseProcessedSize(ullDiff); m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullDiff); @@ -558,7 +451,7 @@ return eResult; else if(!fileDst.IsOpen()) { - unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tProgressInfo.GetCurrentFileProcessedSize(); + unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize(); m_tSubTaskStats.IncreaseProcessedSize(ullDiff); m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullDiff); @@ -572,7 +465,7 @@ if(pData->bOnlyCreate) { // we don't copy contents, but need to increase processed size - unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tProgressInfo.GetCurrentFileProcessedSize(); + unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize(); m_tSubTaskStats.IncreaseProcessedSize(ullDiff); m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullDiff); @@ -591,7 +484,7 @@ return eResult; else if(bSkip) { - unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tProgressInfo.GetCurrentFileProcessedSize(); + unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize(); m_tSubTaskStats.IncreaseProcessedSize(ullDiff); m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullDiff); @@ -606,7 +499,7 @@ else if(bSkip) { // with either first or second seek we got 'skip' answer... - unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tProgressInfo.GetCurrentFileProcessedSize(); + unsigned long long ullDiff = pData->spSrcFile->GetLength64() - m_tSubTaskStats.GetCurrentItemProcessedSize(); m_tSubTaskStats.IncreaseProcessedSize(ullDiff); m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullDiff); @@ -615,20 +508,13 @@ return TSubTaskBase::eSubResult_Continue; } - // ullSeekTo (== m_tProgressInfo.GetCurrentFileProcessedSize()) is already a part of stats + // ullSeekTo (== m_tSubTaskStats.GetCurrentItemProcessedSize()) is already a part of stats // so the only correction that might need to be done is subtracting the difference // between stored last file position (aka ullSeekTo) and the real position // to which the file pos was set to. m_tSubTaskStats.SetCurrentItemProcessedSize(ullMove); if(ullMove < ullSeekTo) - { - unsigned long long ullDiff = ullSeekTo - ullMove; - - m_tProgressInfo.DecreaseCurrentFileProcessedSize(ullDiff); - // new stats - m_tSubTaskStats.IncreaseProcessedSize(ullMove); - m_tSubTaskStats.IncreaseCurrentItemProcessedSize(ullMove); - } + m_tSubTaskStats.DecreaseProcessedSize(ullSeekTo - ullMove); } // if the destination file already exists - truncate it to the current file position @@ -1192,7 +1078,7 @@ return eResult; // move file pointer to the end of destination file - eResult = SetFilePointerFB(file, m_tProgressInfo.GetCurrentFileProcessedSize() + rdwBytesWritten, pathFile, bSkip); + eResult = SetFilePointerFB(file, m_tSubTaskStats.GetCurrentItemProcessedSize() + rdwBytesWritten, pathFile, bSkip); if(eResult != TSubTaskBase::eSubResult_Continue || bSkip) return eResult; } @@ -1272,7 +1158,7 @@ rLog.logi(_T("Checking for free space on destination disk...")); - ullNeededSize = rFilesCache.CalculateTotalSize() - rFilesCache.CalculatePartialSize(m_tProgressInfo.GetCurrentIndex()); // it'd be nice to round up to take cluster size into consideration + ullNeededSize = rFilesCache.CalculateTotalSize() - rFilesCache.CalculatePartialSize(m_tSubTaskStats.GetCurrentIndex()); // it'd be nice to round up to take cluster size into consideration // get free space bool bResult = rLocalFilesystem.GetDynamicFreeSpace(pathDestination, ullAvailableSize); @@ -1316,15 +1202,13 @@ return TSubTaskBase::eSubResult_Continue; } - void TSubTaskCopyMove::Store(const ISerializerPtr& spSerializer) const { ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtask_copymove")); InitColumns(spContainer); - ISerializerRowData& rRow = spContainer->GetRow(0, !m_tProgressInfo.WasSerialized()); + ISerializerRowData& rRow = spContainer->GetRow(0, m_tSubTaskStats.WasAdded()); - m_tProgressInfo.Store(rRow); m_tSubTaskStats.Store(rRow); } @@ -1336,20 +1220,14 @@ ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); if(spRowReader->Next()) - { - m_tProgressInfo.Load(spRowReader); m_tSubTaskStats.Load(spRowReader); - } } void TSubTaskCopyMove::InitColumns(const ISerializerContainerPtr& spContainer) const { IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); if(rColumns.IsEmpty()) - { - details::TCopyMoveProgressInfo::InitColumns(rColumns); TSubTaskStatsInfo::InitColumns(rColumns); - } } END_CHCORE_NAMESPACE Index: src/libchcore/TSubTaskCopyMove.h =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -38,56 +38,6 @@ class TSimpleDataBuffer; class TBufferSizes; -namespace details -{ - /////////////////////////////////////////////////////////////////////////// - // TCopyMoveProgressInfo - - class TCopyMoveProgressInfo : public TSubTaskProgressInfo - { - public: - TCopyMoveProgressInfo(); - virtual ~TCopyMoveProgressInfo(); - - virtual void ResetProgress(); - - // file being processed - void SetCurrentIndex(file_count_t fcIndex); - void IncreaseCurrentIndex(); - file_count_t GetCurrentIndex() const; - - // part of file being processed - void SetCurrentFileProcessedSize(unsigned long long ullSize); - unsigned long long GetCurrentFileProcessedSize() const; - void IncreaseCurrentFileProcessedSize(unsigned long long ullSizeToAdd); - void DecreaseCurrentFileProcessedSize(unsigned long long ullSizeToSubtract); - - void Store(ISerializerRowData& rRowData) const; - static void InitColumns(IColumnsDefinition& rColumns); - void Load(const ISerializerRowReaderPtr& spRowReader); - bool WasSerialized() const; - - private: - enum EModifications - { - eMod_Added, - eMod_CurrentIndex, - eMod_CurrentFileProcessedSize, - - // last item - eMod_Last - }; - - typedef std::bitset Bitset; - mutable Bitset m_setModifications; - - TSharedModificationTracker m_fcCurrentIndex; - TSharedModificationTracker m_ullCurrentFileProcessedSize; // count of bytes processed for current file - - mutable boost::shared_mutex m_lock; - }; -} - class LIBCHCORE_API TSubTaskCopyMove : public TSubTaskBase { public: @@ -103,7 +53,6 @@ void InitColumns(const ISerializerContainerPtr& spContainer) const; - virtual TSubTaskProgressInfo& GetProgressInfo() { return m_tProgressInfo; } virtual void GetStatsSnapshot(TSubTaskStatsSnapshotPtr& rStats) const; private: @@ -131,7 +80,6 @@ private: #pragma warning(push) #pragma warning(disable: 4251) - details::TCopyMoveProgressInfo m_tProgressInfo; TSubTaskStatsInfo m_tSubTaskStats; #pragma warning(pop) }; Index: src/libchcore/TSubTaskDelete.cpp =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -38,76 +38,6 @@ BEGIN_CHCORE_NAMESPACE -namespace details -{ - /////////////////////////////////////////////////////////////////////////////////////////////////// - // class TDeleteProgressInfo - - TDeleteProgressInfo::TDeleteProgressInfo() : - m_fcCurrentIndex(0), - m_fcLastStoredIndex((file_count_t)-1) - { - } - - TDeleteProgressInfo::~TDeleteProgressInfo() - { - } - - void TDeleteProgressInfo::ResetProgress() - { - boost::unique_lock lock(m_lock); - m_fcCurrentIndex = 0; - } - - void TDeleteProgressInfo::SetCurrentIndex(file_count_t fcIndex) - { - boost::unique_lock lock(m_lock); - m_fcCurrentIndex = fcIndex; - } - - void TDeleteProgressInfo::IncreaseCurrentIndex() - { - boost::unique_lock lock(m_lock); - ++m_fcCurrentIndex; - } - - file_count_t TDeleteProgressInfo::GetCurrentIndex() const - { - boost::shared_lock lock(m_lock); - return m_fcCurrentIndex; - } - - void TDeleteProgressInfo::Store(ISerializerRowData& rRowData) const - { - boost::shared_lock lock(m_lock); - if(m_fcCurrentIndex != m_fcLastStoredIndex) - { - rRowData.SetValue(_T("current_index"), m_fcCurrentIndex); - m_fcLastStoredIndex = m_fcCurrentIndex; - } - } - - void TDeleteProgressInfo::InitColumns(IColumnsDefinition& rColumns) - { - rColumns.AddColumn(_T("id"), ColumnType::value); - rColumns.AddColumn(_T("current_index"), ColumnType::value); - } - - void TDeleteProgressInfo::Load(const ISerializerRowReaderPtr& spRowReader) - { - boost::unique_lock lock(m_lock); - - spRowReader->GetValue(_T("current_index"), m_fcCurrentIndex); - m_fcLastStoredIndex = m_fcCurrentIndex; - } - - bool TDeleteProgressInfo::WasSerialized() const - { - boost::shared_lock lock(m_lock); - return m_fcLastStoredIndex != (file_count_t)-1; - } -} - /////////////////////////////////////////////////////////////////////////////////////////////////// // class TSubTaskDelete @@ -119,7 +49,6 @@ void TSubTaskDelete::Reset() { - m_tProgressInfo.ResetProgress(); m_tSubTaskStats.Clear(); } @@ -151,12 +80,12 @@ TString strFormat; // index points to 0 or next item to process - file_count_t fcIndex = m_tProgressInfo.GetCurrentIndex(); + file_count_t fcIndex = m_tSubTaskStats.GetCurrentIndex(); while(fcIndex < rFilesCache.GetSize()) { spFileInfo = rFilesCache.GetAt(rFilesCache.GetSize() - fcIndex - 1); - m_tProgressInfo.SetCurrentIndex(fcIndex); + m_tSubTaskStats.SetCurrentIndex(fcIndex); // new stats m_tSubTaskStats.SetProcessedCount(fcIndex); @@ -228,9 +157,7 @@ ++fcIndex; }//while - m_tProgressInfo.SetCurrentIndex(fcIndex); - - // new stats + m_tSubTaskStats.SetCurrentIndex(fcIndex); m_tSubTaskStats.SetProcessedCount(fcIndex); m_tSubTaskStats.SetCurrentPath(TString()); @@ -256,9 +183,8 @@ ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtask_delete")); InitColumns(spContainer); - ISerializerRowData& rRow = spContainer->GetRow(0, !m_tProgressInfo.WasSerialized()); + ISerializerRowData& rRow = spContainer->GetRow(0, m_tSubTaskStats.WasAdded()); - m_tProgressInfo.Store(rRow); m_tSubTaskStats.Store(rRow); } @@ -270,20 +196,14 @@ ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); if(spRowReader->Next()) - { - m_tProgressInfo.Load(spRowReader); m_tSubTaskStats.Load(spRowReader); - } } void TSubTaskDelete::InitColumns(const ISerializerContainerPtr& spContainer) const { IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); if(rColumns.IsEmpty()) - { - details::TDeleteProgressInfo::InitColumns(rColumns); TSubTaskStatsInfo::InitColumns(rColumns); - } } END_CHCORE_NAMESPACE Index: src/libchcore/TSubTaskDelete.h =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskDelete.h (.../TSubTaskDelete.h) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSubTaskDelete.h (.../TSubTaskDelete.h) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -28,35 +28,6 @@ BEGIN_CHCORE_NAMESPACE -namespace details -{ - /////////////////////////////////////////////////////////////////////////// - // TDeleteProgressInfo - - class TDeleteProgressInfo : public TSubTaskProgressInfo - { - public: - TDeleteProgressInfo(); - virtual ~TDeleteProgressInfo(); - - virtual void ResetProgress(); - - void SetCurrentIndex(file_count_t fcIndex); - void IncreaseCurrentIndex(); - file_count_t GetCurrentIndex() const; - - void Store(ISerializerRowData& rRowData) const; - static void InitColumns(IColumnsDefinition& rColumns); - void Load(const ISerializerRowReaderPtr& spRowReader); - bool WasSerialized() const; - - private: - file_count_t m_fcCurrentIndex; - mutable file_count_t m_fcLastStoredIndex; - mutable boost::shared_mutex m_lock; - }; -} - /////////////////////////////////////////////////////////////////////////// // TSubTaskDelete @@ -75,13 +46,11 @@ void InitColumns(const ISerializerContainerPtr& spContainer) const; - virtual TSubTaskProgressInfo& GetProgressInfo() { return m_tProgressInfo; } virtual void GetStatsSnapshot(TSubTaskStatsSnapshotPtr& spStats) const; private: #pragma warning(push) #pragma warning(disable: 4251) - details::TDeleteProgressInfo m_tProgressInfo; TSubTaskStatsInfo m_tSubTaskStats; #pragma warning(pop) }; Index: src/libchcore/TSubTaskFastMove.cpp =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -40,76 +40,6 @@ BEGIN_CHCORE_NAMESPACE -namespace details -{ - /////////////////////////////////////////////////////////////////////////////////////////////////// - // class TFastMoveProgressInfo - - TFastMoveProgressInfo::TFastMoveProgressInfo() : - m_fcCurrentIndex(0), - m_fcLastStoredIndex((file_count_t)-1) - { - } - - TFastMoveProgressInfo::~TFastMoveProgressInfo() - { - } - - void TFastMoveProgressInfo::ResetProgress() - { - boost::unique_lock lock(m_lock); - m_fcCurrentIndex = 0; - } - - void TFastMoveProgressInfo::SetCurrentIndex(file_count_t fcIndex) - { - boost::unique_lock lock(m_lock); - m_fcCurrentIndex = fcIndex; - } - - void TFastMoveProgressInfo::IncreaseCurrentIndex() - { - boost::unique_lock lock(m_lock); - ++m_fcCurrentIndex; - } - - file_count_t TFastMoveProgressInfo::GetCurrentIndex() const - { - boost::shared_lock lock(m_lock); - return m_fcCurrentIndex; - } - - void TFastMoveProgressInfo::Store(ISerializerRowData& rRowData) const - { - boost::shared_lock lock(m_lock); - if(m_fcCurrentIndex != m_fcLastStoredIndex) - { - rRowData.SetValue(_T("current_index"), m_fcCurrentIndex); - m_fcLastStoredIndex = m_fcCurrentIndex; - } - } - - void TFastMoveProgressInfo::InitColumns(IColumnsDefinition& rColumns) - { - rColumns.AddColumn(_T("id"), ColumnType::value); - rColumns.AddColumn(_T("current_index"), ColumnType::value); - } - - void TFastMoveProgressInfo::Load(const ISerializerRowReaderPtr& spRowReader) - { - boost::unique_lock lock(m_lock); - - spRowReader->GetValue(_T("current_index"), m_fcCurrentIndex); - m_fcLastStoredIndex = m_fcCurrentIndex; - } - - bool TFastMoveProgressInfo::WasSerialized() const - { - boost::shared_lock lock(m_lock); - return m_fcLastStoredIndex != (file_count_t)-1; - } -} - TSubTaskFastMove::TSubTaskFastMove(TSubTaskContext& rContext) : TSubTaskBase(rContext) { @@ -122,7 +52,6 @@ void TSubTaskFastMove::Reset() { - m_tProgressInfo.ResetProgress(); m_tSubTaskStats.Clear(); } @@ -163,14 +92,14 @@ bool bSkipInputPath = false; file_count_t fcSize = spBasePaths->GetCount(); - file_count_t fcIndex = m_tProgressInfo.GetCurrentIndex(); + file_count_t fcIndex = m_tSubTaskStats.GetCurrentIndex(); for(; fcIndex < fcSize ; fcIndex++) { TBasePathDataPtr spBasePath = spBasePaths->GetAt(fcIndex); TSmartPath pathCurrent = spBasePath->GetSrcPath(); // store currently processed index - m_tProgressInfo.SetCurrentIndex(fcIndex); + m_tSubTaskStats.SetCurrentIndex(fcIndex); // new stats m_tSubTaskStats.SetProcessedCount(fcIndex); @@ -293,9 +222,7 @@ } } - m_tProgressInfo.SetCurrentIndex(fcIndex); - - // new stats + m_tSubTaskStats.SetCurrentIndex(fcIndex); m_tSubTaskStats.SetProcessedCount(fcIndex); m_tSubTaskStats.SetCurrentPath(TString()); @@ -316,9 +243,8 @@ InitColumns(spContainer); - ISerializerRowData& rRow = spContainer->GetRow(0, !m_tProgressInfo.WasSerialized()); + ISerializerRowData& rRow = spContainer->GetRow(0, m_tSubTaskStats.WasAdded()); - m_tProgressInfo.Store(rRow); m_tSubTaskStats.Store(rRow); } @@ -330,20 +256,14 @@ ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); if(spRowReader->Next()) - { - m_tProgressInfo.Load(spRowReader); m_tSubTaskStats.Load(spRowReader); - } } void TSubTaskFastMove::InitColumns(const ISerializerContainerPtr& spContainer) const { IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition(); if(rColumns.IsEmpty()) - { - details::TFastMoveProgressInfo::InitColumns(rColumns); TSubTaskStatsInfo::InitColumns(rColumns); - } } END_CHCORE_NAMESPACE Index: src/libchcore/TSubTaskFastMove.h =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskFastMove.h (.../TSubTaskFastMove.h) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSubTaskFastMove.h (.../TSubTaskFastMove.h) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -32,35 +32,6 @@ class TFileFiltersArray; -namespace details -{ - /////////////////////////////////////////////////////////////////////////// - // TFastMoveProgressInfo - - class TFastMoveProgressInfo : public TSubTaskProgressInfo - { - public: - TFastMoveProgressInfo(); - virtual ~TFastMoveProgressInfo(); - - virtual void ResetProgress(); - - void SetCurrentIndex(file_count_t fcIndex); - void IncreaseCurrentIndex(); - file_count_t GetCurrentIndex() const; - - void Store(ISerializerRowData& rRowData) const; - static void InitColumns(IColumnsDefinition& rColumns); - void Load(const ISerializerRowReaderPtr& spRowReader); - bool WasSerialized() const; - - private: - file_count_t m_fcCurrentIndex; - mutable file_count_t m_fcLastStoredIndex; - mutable boost::shared_mutex m_lock; - }; -} - /////////////////////////////////////////////////////////////////////////// // TSubTaskFastMove @@ -80,7 +51,6 @@ void InitColumns(const ISerializerContainerPtr& spContainer) const; - virtual TSubTaskProgressInfo& GetProgressInfo() { return m_tProgressInfo; } virtual void GetStatsSnapshot(TSubTaskStatsSnapshotPtr& rStats) const; private: @@ -89,7 +59,6 @@ private: #pragma warning(push) #pragma warning(disable: 4251) - details::TFastMoveProgressInfo m_tProgressInfo; TSubTaskStatsInfo m_tSubTaskStats; #pragma warning(pop) }; Index: src/libchcore/TSubTaskScanDirectory.cpp =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -40,45 +40,6 @@ BEGIN_CHCORE_NAMESPACE -namespace details -{ - /////////////////////////////////////////////////////////////////////////////////////////////////// - // class TScanDirectoriesProgressInfo - - TScanDirectoriesProgressInfo::TScanDirectoriesProgressInfo() : - m_fcCurrentIndex(0) - { - } - - TScanDirectoriesProgressInfo::~TScanDirectoriesProgressInfo() - { - } - - void TScanDirectoriesProgressInfo::ResetProgress() - { - boost::unique_lock lock(m_lock); - m_fcCurrentIndex = 0; - } - - void TScanDirectoriesProgressInfo::SetCurrentIndex(file_count_t fcIndex) - { - boost::unique_lock lock(m_lock); - m_fcCurrentIndex = fcIndex; - } - - void TScanDirectoriesProgressInfo::IncreaseCurrentIndex() - { - boost::unique_lock lock(m_lock); - ++m_fcCurrentIndex; - } - - file_count_t TScanDirectoriesProgressInfo::GetCurrentIndex() const - { - boost::shared_lock lock(m_lock); - return m_fcCurrentIndex; - } -} - /////////////////////////////////////////////////////////////////////////////////////////////////// // class TSubTaskScanDirectories TSubTaskScanDirectories::TSubTaskScanDirectories(TSubTaskContext& rContext) : @@ -93,7 +54,6 @@ void TSubTaskScanDirectories::Reset() { - m_tProgressInfo.ResetProgress(); m_tSubTaskStats.Clear(); } @@ -136,13 +96,13 @@ file_count_t fcSize = spBasePaths->GetCount(); // NOTE: in theory, we should resume the scanning, but in practice we are always restarting scanning if interrupted. - file_count_t fcIndex = 0; // m_tProgressInfo.GetCurrentIndex() + file_count_t fcIndex = 0; // m_tSubTaskStats.GetCurrentIndex() for(; fcIndex < fcSize; fcIndex++) { TBasePathDataPtr spBasePath = spBasePaths->GetAt(fcIndex); TSmartPath pathCurrent = spBasePath->GetSrcPath(); - m_tProgressInfo.SetCurrentIndex(fcIndex); + m_tSubTaskStats.SetCurrentIndex(fcIndex); // new stats m_tSubTaskStats.SetProcessedCount(fcIndex); @@ -246,10 +206,8 @@ } } - // calc size of all files - m_tProgressInfo.SetCurrentIndex(fcIndex); - - // new stats + // update stats + m_tSubTaskStats.SetCurrentIndex(fcIndex); m_tSubTaskStats.SetProcessedCount(fcIndex); m_tSubTaskStats.SetCurrentPath(TString()); Index: src/libchcore/TSubTaskScanDirectory.h =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskScanDirectory.h (.../TSubTaskScanDirectory.h) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSubTaskScanDirectory.h (.../TSubTaskScanDirectory.h) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -33,29 +33,6 @@ class TFileFiltersArray; -namespace details -{ - /////////////////////////////////////////////////////////////////////////// - // TScanDirectoriesProgressInfo - - class TScanDirectoriesProgressInfo : public TSubTaskProgressInfo - { - public: - TScanDirectoriesProgressInfo(); - virtual ~TScanDirectoriesProgressInfo(); - - virtual void ResetProgress(); - - void SetCurrentIndex(file_count_t fcIndex); - void IncreaseCurrentIndex(); - file_count_t GetCurrentIndex() const; - - private: - file_count_t m_fcCurrentIndex; - mutable boost::shared_mutex m_lock; - }; -} - /////////////////////////////////////////////////////////////////////////// // TSubTaskScanDirectories @@ -73,7 +50,6 @@ virtual void Store(const ISerializerPtr& spSerializer) const; virtual void Load(const ISerializerPtr& spSerializer); - virtual TSubTaskProgressInfo& GetProgressInfo() { return m_tProgressInfo; } virtual void GetStatsSnapshot(TSubTaskStatsSnapshotPtr& spStats) const; private: @@ -83,7 +59,6 @@ private: #pragma warning(push) #pragma warning(disable: 4251) - details::TScanDirectoriesProgressInfo m_tProgressInfo; TSubTaskStatsInfo m_tSubTaskStats; #pragma warning(pop) }; Index: src/libchcore/TSubTaskStatsInfo.cpp =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskStatsInfo.cpp (.../TSubTaskStatsInfo.cpp) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSubTaskStatsInfo.cpp (.../TSubTaskStatsInfo.cpp) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -27,6 +27,7 @@ #include "TSubTaskStatsSnapshot.h" #include "TCoreException.h" #include "ErrorCodes.h" +#include "SerializerDataTypes.h" BEGIN_CHCORE_NAMESPACE @@ -62,8 +63,10 @@ m_ullCurrentItemTotalSize(m_setModifications, 0), m_eSubOperationType(m_setModifications, eSubOperation_None), m_tTimer(m_setModifications), - m_bIsInitialized(m_setModifications, false) + m_bIsInitialized(m_setModifications, false), + m_fcCurrentIndex(m_setModifications, 0) { + m_setModifications[eMod_Added] = true; } void TSubTaskStatsInfo::Clear() @@ -82,6 +85,7 @@ m_ullCurrentItemTotalSize = 0; m_eSubOperationType = eSubOperation_None; m_bIsInitialized = false; + m_fcCurrentIndex = 0; } void TSubTaskStatsInfo::GetSnapshot(TSubTaskStatsSnapshotPtr& spStatsSnapshot) const @@ -108,6 +112,7 @@ spStatsSnapshot->SetCurrentItemProcessedSize(m_ullCurrentItemProcessedSize); spStatsSnapshot->SetCurrentItemTotalSize(m_ullCurrentItemTotalSize); spStatsSnapshot->SetSubOperationType(m_eSubOperationType); + spStatsSnapshot->SetCurrentIndex(m_fcCurrentIndex); } // is running? @@ -305,6 +310,8 @@ rRowData.SetValue(_T("ci_processed_size"), m_ullCurrentItemProcessedSize); if(m_ullCurrentItemTotalSize.IsModified()) rRowData.SetValue(_T("ci_total_size"), m_ullCurrentItemTotalSize); + if(m_fcCurrentIndex.IsModified()) + rRowData.SetValue(_T("current_index"), m_fcCurrentIndex); if(m_tTimer.IsModified()) rRowData.SetValue(_T("timer"), m_tTimer.Get().GetTotalTime()); @@ -322,6 +329,7 @@ void TSubTaskStatsInfo::InitColumns(IColumnsDefinition& rColumnDefs) { + rColumnDefs.AddColumn(_T("id"), ColumnType::value); rColumnDefs.AddColumn(_T("is_running"), IColumnsDefinition::eType_bool); rColumnDefs.AddColumn(_T("is_initialized"), IColumnsDefinition::eType_bool); rColumnDefs.AddColumn(_T("total_size"), IColumnsDefinition::eType_ulonglong); @@ -332,6 +340,7 @@ rColumnDefs.AddColumn(_T("count_speed"), IColumnsDefinition::eType_string); rColumnDefs.AddColumn(_T("ci_processed_size"), IColumnsDefinition::eType_ulonglong); rColumnDefs.AddColumn(_T("ci_total_size"), IColumnsDefinition::eType_ulonglong); + rColumnDefs.AddColumn(_T("current_index"), ColumnType::value); rColumnDefs.AddColumn(_T("timer"), IColumnsDefinition::eType_ulonglong); rColumnDefs.AddColumn(_T("buffer_index"), IColumnsDefinition::eType_int); rColumnDefs.AddColumn(_T("current_path"), IColumnsDefinition::eType_string); @@ -361,6 +370,7 @@ spRowReader->GetValue(_T("ci_processed_size"), m_ullCurrentItemProcessedSize.Modify()); spRowReader->GetValue(_T("ci_total_size"), m_ullCurrentItemTotalSize.Modify()); + spRowReader->GetValue(_T("current_index"), m_fcCurrentIndex.Modify()); unsigned long long ullTimer = 0; spRowReader->GetValue(_T("timer"), ullTimer); @@ -409,4 +419,34 @@ return bInitialized; } +void TSubTaskStatsInfo::SetCurrentIndex(file_count_t fcIndex) +{ + boost::unique_lock lock(m_lock); + m_fcCurrentIndex = fcIndex; +} + +chcore::file_count_t TSubTaskStatsInfo::GetCurrentIndex() const +{ + boost::shared_lock lock(m_lock); + return m_fcCurrentIndex.Get(); +} + +unsigned long long TSubTaskStatsInfo::GetCurrentItemProcessedSize() const +{ + boost::shared_lock lock(m_lock); + return m_ullCurrentItemProcessedSize; +} + +unsigned long long TSubTaskStatsInfo::GetCurrentItemTotalSize() const +{ + boost::shared_lock lock(m_lock); + return m_ullCurrentItemTotalSize; +} + +bool TSubTaskStatsInfo::WasAdded() const +{ + boost::shared_lock lock(m_lock); + return m_setModifications[eMod_Added]; +} + END_CHCORE_NAMESPACE Index: src/libchcore/TSubTaskStatsInfo.h =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskStatsInfo.h (.../TSubTaskStatsInfo.h) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSubTaskStatsInfo.h (.../TSubTaskStatsInfo.h) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -66,6 +66,7 @@ void Init(int iCurrentBufferIndex, file_count_t fcTotalCount, file_count_t fcProcessedCount, unsigned long long ullTotalSize, unsigned long long ullProcessedSize, const TString& strCurrentPath); void Clear(); + bool WasAdded() const; bool IsInitialized() const; @@ -90,6 +91,13 @@ void SetCurrentItemTotalSize(unsigned long long ullTotalSize); + unsigned long long GetCurrentItemProcessedSize() const; + unsigned long long GetCurrentItemTotalSize() const; + + // current index + void SetCurrentIndex(file_count_t fcIndex); + file_count_t GetCurrentIndex() const; + // buffer index void SetCurrentBufferIndex(int iCurrentIndex); @@ -135,6 +143,7 @@ eMod_CurrentPath, eMod_SubOperationType, eMod_IsInitialized, + eMod_CurrentItemIndex, // last item eMod_Last @@ -153,6 +162,8 @@ TSharedModificationTracker m_fcProcessedCount; mutable TSharedModificationTracker m_tCountSpeed; + TSharedModificationTracker m_fcCurrentIndex; + TSharedModificationTracker m_ullCurrentItemProcessedSize; TSharedModificationTracker m_ullCurrentItemTotalSize; Index: src/libchcore/TSubTaskStatsSnapshot.cpp =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskStatsSnapshot.cpp (.../TSubTaskStatsSnapshot.cpp) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSubTaskStatsSnapshot.cpp (.../TSubTaskStatsSnapshot.cpp) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -43,7 +43,8 @@ m_dCountSpeed(0), m_ullCurrentItemProcessedSize(0), m_ullCurrentItemTotalSize(0), - m_eSubOperationType(eSubOperation_None) + m_eSubOperationType(eSubOperation_None), + m_fcCurrentIndex(0) { } @@ -62,6 +63,7 @@ m_ullCurrentItemProcessedSize = 0; m_ullCurrentItemTotalSize = 0; m_eSubOperationType = eSubOperation_None; + m_fcCurrentIndex = 0; } double TSubTaskStatsSnapshot::CalculateProgress() const Index: src/libchcore/TSubTaskStatsSnapshot.h =================================================================== diff -u -ra44714d5c7ec0f50a376f4d0ea919ee5a224f834 -rd76d3ce6c8c55fa23009dbb03b8bc06f482c5b72 --- src/libchcore/TSubTaskStatsSnapshot.h (.../TSubTaskStatsSnapshot.h) (revision a44714d5c7ec0f50a376f4d0ea919ee5a224f834) +++ src/libchcore/TSubTaskStatsSnapshot.h (.../TSubTaskStatsSnapshot.h) (revision d76d3ce6c8c55fa23009dbb03b8bc06f482c5b72) @@ -62,6 +62,9 @@ void SetCurrentItemTotalSize(unsigned long long ullTotalSize) { m_ullCurrentItemTotalSize = ullTotalSize; } unsigned long long GetCurrentItemTotalSize() const { return m_ullCurrentItemTotalSize; } + void SetCurrentIndex(file_count_t fcCurrentIndex) { m_fcCurrentIndex = fcCurrentIndex; } + file_count_t GetCurrentIndex() const { return m_fcCurrentIndex; } + // progress in percent double GetCombinedProgress() const; // returns progress [0.0, 1.0] @@ -111,6 +114,7 @@ // current item size unsigned long long m_ullCurrentItemTotalSize; unsigned long long m_ullCurrentItemProcessedSize; + file_count_t m_fcCurrentIndex; ESubOperationType m_eSubOperationType;