Index: src/libchcore/TSubTaskFastMove.cpp =================================================================== diff -u -N -r297ce850732d4243414c851df145ca97bd696baa -rbebda797ec6983535a8940f8f9f15453fe6b1785 --- src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision 297ce850732d4243414c851df145ca97bd696baa) +++ src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision bebda797ec6983535a8940f8f9f15453fe6b1785) @@ -33,11 +33,63 @@ #include "TTaskLocalStats.h" #include "..\libicpf\log.h" #include "TFileInfo.h" -#include "TBasicProgressInfo.h" #include +#include "SerializationHelpers.h" +#include "TBinarySerializer.h" BEGIN_CHCORE_NAMESPACE +namespace details +{ + /////////////////////////////////////////////////////////////////////////////////////////////////// + // class TFastMoveProgressInfo + + TFastMoveProgressInfo::TFastMoveProgressInfo() : + m_stCurrentIndex(0) + { + } + + TFastMoveProgressInfo::~TFastMoveProgressInfo() + { + } + + void TFastMoveProgressInfo::Serialize(TReadBinarySerializer& rSerializer) + { + boost::unique_lock lock(m_lock); + Serializers::Serialize(rSerializer, m_stCurrentIndex); + } + + void TFastMoveProgressInfo::Serialize(TWriteBinarySerializer& rSerializer) const + { + boost::shared_lock lock(m_lock); + Serializers::Serialize(rSerializer, m_stCurrentIndex); + } + + void TFastMoveProgressInfo::ResetProgress() + { + boost::unique_lock lock(m_lock); + m_stCurrentIndex = 0; + } + + void TFastMoveProgressInfo::SetCurrentIndex(size_t stIndex) + { + boost::unique_lock lock(m_lock); + m_stCurrentIndex = stIndex; + } + + void TFastMoveProgressInfo::IncreaseCurrentIndex() + { + boost::unique_lock lock(m_lock); + ++m_stCurrentIndex; + } + + size_t TFastMoveProgressInfo::GetCurrentIndex() const + { + boost::shared_lock lock(m_lock); + return m_stCurrentIndex; + } +} + TSubTaskFastMove::TSubTaskFastMove(TSubTaskContext& rContext) : TSubTaskBase(rContext) { @@ -55,14 +107,16 @@ IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); TTaskLocalStats& rTaskLocalStats = GetContext().GetTaskLocalStats(); - TTaskBasicProgressInfo& rProgressInfo = GetContext().GetTaskBasicProgressInfo(); TBasePathDataContainer& rBasePathDataContainer = GetContext().GetBasePathDataContainer(); rLog.logi(_T("Performing initial fast-move operation...")); // reset progress rTaskLocalStats.SetProcessedSize(0); rTaskLocalStats.SetTotalSize(0); + rTaskLocalStats.SetCurrentIndex(0); + rTaskLocalStats.SetTotalItems(rTaskDefinition.GetSourcePathCount()); + rTaskLocalStats.SetCurrentPath(TString()); // read filtering options TFileFiltersArray afFilters; @@ -84,11 +138,17 @@ bool bSkipInputPath = false; size_t stSize = rTaskDefinition.GetSourcePathCount(); - for(size_t stIndex = rProgressInfo.GetCurrentIndex(); stIndex < stSize ; stIndex++) + size_t stIndex = m_tProgressInfo.GetCurrentIndex(); + for(; stIndex < stSize ; stIndex++) { + TSmartPath pathCurrent = rTaskDefinition.GetSourcePathAt(stIndex); + // store currently processed index - rProgressInfo.SetCurrentIndex(stIndex); + m_tProgressInfo.SetCurrentIndex(stIndex); + rTaskLocalStats.SetCurrentIndex(stIndex); + rTaskLocalStats.SetCurrentPath(pathCurrent.ToString()); + // retrieve base path data TBasePathDataPtr spBasePathData = rBasePathDataContainer.GetAt(stIndex); if(!spBasePathData) @@ -106,7 +166,7 @@ bRetry = false; // read attributes of src file/folder - bool bExists = TLocalFilesystem::GetFileInfo(rTaskDefinition.GetSourcePathAt(stIndex), spFileInfo, stIndex, &rTaskDefinition.GetSourcePaths()); + bool bExists = TLocalFilesystem::GetFileInfo(pathCurrent, spFileInfo, stIndex, &rTaskDefinition.GetSourcePaths()); if(!bExists) { FEEDBACK_FILEERROR ferr = { rTaskDefinition.GetSourcePathAt(stIndex).ToString(), NULL, eFastMoveError, ERROR_FILE_NOT_FOUND }; @@ -209,6 +269,11 @@ } } + m_tProgressInfo.SetCurrentIndex(stIndex); + rTaskLocalStats.SetCurrentIndex(stIndex); + rTaskLocalStats.SetCurrentPath(TString()); + + // log rLog.logi(_T("Fast moving finished"));