Index: src/libchcore/TSubTaskDelete.cpp =================================================================== diff -u -N -r297ce850732d4243414c851df145ca97bd696baa -rbebda797ec6983535a8940f8f9f15453fe6b1785 --- src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision 297ce850732d4243414c851df145ca97bd696baa) +++ src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision bebda797ec6983535a8940f8f9f15453fe6b1785) @@ -23,7 +23,6 @@ #include "stdafx.h" #include "TSubTaskDelete.h" #include "TSubTaskContext.h" -#include "TBasicProgressInfo.h" #include "TWorkerThreadController.h" #include "TTaskConfiguration.h" #include "TTaskDefinition.h" @@ -33,9 +32,66 @@ #include #include "TFileInfoArray.h" #include "TFileInfo.h" +#include "SerializationHelpers.h" +#include "TBinarySerializer.h" +#include "TTaskLocalStats.h" BEGIN_CHCORE_NAMESPACE +namespace details +{ + /////////////////////////////////////////////////////////////////////////////////////////////////// + // class TDeleteProgressInfo + + TDeleteProgressInfo::TDeleteProgressInfo() : + m_stCurrentIndex(0) + { + } + + TDeleteProgressInfo::~TDeleteProgressInfo() + { + } + + void TDeleteProgressInfo::Serialize(TReadBinarySerializer& rSerializer) + { + boost::unique_lock lock(m_lock); + Serializers::Serialize(rSerializer, m_stCurrentIndex); + } + + void TDeleteProgressInfo::Serialize(TWriteBinarySerializer& rSerializer) const + { + boost::shared_lock lock(m_lock); + Serializers::Serialize(rSerializer, m_stCurrentIndex); + } + + void TDeleteProgressInfo::ResetProgress() + { + boost::unique_lock lock(m_lock); + m_stCurrentIndex = 0; + } + + void TDeleteProgressInfo::SetCurrentIndex(size_t stIndex) + { + boost::unique_lock lock(m_lock); + m_stCurrentIndex = stIndex; + } + + void TDeleteProgressInfo::IncreaseCurrentIndex() + { + boost::unique_lock lock(m_lock); + ++m_stCurrentIndex; + } + + size_t TDeleteProgressInfo::GetCurrentIndex() const + { + boost::shared_lock lock(m_lock); + return m_stCurrentIndex; + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// class TSubTaskDelete + TSubTaskDelete::TSubTaskDelete(TSubTaskContext& rContext) : TSubTaskBase(rContext) { @@ -47,25 +103,35 @@ icpf::log_file& rLog = GetContext().GetLog(); TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); - TTaskBasicProgressInfo& rBasicProgressInfo = GetContext().GetTaskBasicProgressInfo(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); + TTaskLocalStats& rTaskLocalStats = GetContext().GetTaskLocalStats(); // log rLog.logi(_T("Deleting files (DeleteFiles)...")); + rTaskLocalStats.SetProcessedSize(0); + rTaskLocalStats.SetTotalSize(0); + rTaskLocalStats.SetCurrentIndex(0); + rTaskLocalStats.SetTotalItems(rFilesCache.GetSize()); + rTaskLocalStats.SetCurrentPath(TString()); + // current processed path BOOL bSuccess; TFileInfoPtr spFileInfo; TString strFormat; // index points to 0 or next item to process - size_t stIndex = rBasicProgressInfo.GetCurrentIndex(); + size_t stIndex = m_tProgressInfo.GetCurrentIndex(); while(stIndex < rFilesCache.GetSize()) { - // set index in pTask to currently deleted element - rBasicProgressInfo.SetCurrentIndex(stIndex); + spFileInfo = rFilesCache.GetAt(rFilesCache.GetSize() - stIndex - 1); + m_tProgressInfo.SetCurrentIndex(stIndex); + + rTaskLocalStats.SetCurrentIndex(stIndex); + rTaskLocalStats.SetCurrentPath(spFileInfo->GetFullFilePath().ToString()); + // check for kill flag if(rThreadController.KillRequested()) { @@ -75,7 +141,6 @@ } // current processed element - spFileInfo = rFilesCache.GetAt(rFilesCache.GetSize() - stIndex - 1); if(!(spFileInfo->GetFlags() & FIF_PROCESSED)) { ++stIndex; @@ -133,8 +198,9 @@ ++stIndex; }//while - // add 1 to current index - rBasicProgressInfo.IncreaseCurrentIndex(); + m_tProgressInfo.SetCurrentIndex(stIndex); + rTaskLocalStats.SetCurrentIndex(stIndex); + rTaskLocalStats.SetCurrentPath(TString()); // log rLog.logi(_T("Deleting files finished"));