Index: src/libchcore/TSubTaskArray.cpp =================================================================== diff -u -rfa1b35a5012ef3fad361edfacd9a627631d55e07 -r3b320bc86d4e808c2f6a70c10bd5c9936102b301 --- src/libchcore/TSubTaskArray.cpp (.../TSubTaskArray.cpp) (revision fa1b35a5012ef3fad361edfacd9a627631d55e07) +++ src/libchcore/TSubTaskArray.cpp (.../TSubTaskArray.cpp) (revision 3b320bc86d4e808c2f6a70c10bd5c9936102b301) @@ -113,6 +113,20 @@ } } + void TSubTasksArray::InitBeforeExec() + { + object_id_t oidSize = boost::numeric_cast(m_vSubTasks.size()); + object_id_t oidIndex = m_oidSubOperationIndex.load(std::memory_order_acquire); + + if(oidIndex < oidSize) + { + std::pair& rCurrentSubTask = m_vSubTasks.at(boost::numeric_cast(oidIndex)); + TSubTaskBasePtr spCurrentSubTask = rCurrentSubTask.first; + + spCurrentSubTask->InitBeforeExec(); + } + } + TSubTaskBase::ESubOperationResult TSubTasksArray::Execute(const IFeedbackHandlerPtr& spFeedbackHandler, bool bRunOnlyEstimationSubTasks) { TSubTaskBase::ESubOperationResult eResult = TSubTaskBase::eSubResult_Continue; @@ -125,6 +139,8 @@ std::pair& rCurrentSubTask = m_vSubTasks.at(boost::numeric_cast(oidIndex)); TSubTaskBasePtr spCurrentSubTask = rCurrentSubTask.first; + spCurrentSubTask->InitBeforeExec(); + // if we run in estimation mode only, then stop processing and return to the caller if (bRunOnlyEstimationSubTasks && !rCurrentSubTask.second) { Index: src/libchcore/TSubTaskArray.h =================================================================== diff -u -rbd349309a6dcd25f8d6dc3348a9dc1c95ac4cc6c -r3b320bc86d4e808c2f6a70c10bd5c9936102b301 --- src/libchcore/TSubTaskArray.h (.../TSubTaskArray.h) (revision bd349309a6dcd25f8d6dc3348a9dc1c95ac4cc6c) +++ src/libchcore/TSubTaskArray.h (.../TSubTaskArray.h) (revision 3b320bc86d4e808c2f6a70c10bd5c9936102b301) @@ -57,6 +57,7 @@ void Store(const ISerializerPtr& spSerializer) const; void Load(const ISerializerPtr& spSerializer); + void InitBeforeExec(); TSubTaskBase::ESubOperationResult Execute(const IFeedbackHandlerPtr& spFeedbackHandler, bool bRunOnlyEstimationSubTasks); // checks if the fast move already marked all base paths as not be be further processed Index: src/libchcore/TSubTaskBase.h =================================================================== diff -u -re96806b7f8ff7ca7e9f4afbea603e6351a3dc3e3 -r3b320bc86d4e808c2f6a70c10bd5c9936102b301 --- src/libchcore/TSubTaskBase.h (.../TSubTaskBase.h) (revision e96806b7f8ff7ca7e9f4afbea603e6351a3dc3e3) +++ src/libchcore/TSubTaskBase.h (.../TSubTaskBase.h) (revision 3b320bc86d4e808c2f6a70c10bd5c9936102b301) @@ -58,6 +58,7 @@ virtual void Reset() = 0; + virtual void InitBeforeExec() = 0; virtual ESubOperationResult Exec(const IFeedbackHandlerPtr& spFeedbackHandler) = 0; virtual ESubOperationType GetSubOperationType() const = 0; Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -rd3b1a109f2ace158e828715205592615d6e33fd0 -r3b320bc86d4e808c2f6a70c10bd5c9936102b301 --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision d3b1a109f2ace158e828715205592615d6e33fd0) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 3b320bc86d4e808c2f6a70c10bd5c9936102b301) @@ -77,6 +77,25 @@ m_tSubTaskStats.Clear(); } + void TSubTaskCopyMove::InitBeforeExec() + { + TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); + + file_count_t fcCount = rFilesCache.GetSize(); + if(fcCount == 0) + { + m_tSubTaskStats.SetCurrentPath(TString()); + return; + } + + file_count_t fcIndex = m_tSubTaskStats.GetCurrentIndex(); + if(fcIndex >= fcCount) + fcIndex = 0; + + TFileInfoPtr spFileInfo = rFilesCache.GetAt(fcIndex); + m_tSubTaskStats.SetCurrentPath(spFileInfo->GetFullFilePath().ToString()); + } + TSubTaskBase::ESubOperationResult TSubTaskCopyMove::Exec(const IFeedbackHandlerPtr& spFeedback) { TScopedRunningTimeTracker guard(m_tSubTaskStats); Index: src/libchcore/TSubTaskCopyMove.h =================================================================== diff -u -r6eefe6212611518e13af7771d406612c0a7a2bed -r3b320bc86d4e808c2f6a70c10bd5c9936102b301 --- src/libchcore/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision 6eefe6212611518e13af7771d406612c0a7a2bed) +++ src/libchcore/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision 3b320bc86d4e808c2f6a70c10bd5c9936102b301) @@ -49,6 +49,7 @@ virtual void Reset(); + virtual void InitBeforeExec() override; virtual ESubOperationResult Exec(const IFeedbackHandlerPtr& spFeedbackHandler) override; virtual ESubOperationType GetSubOperationType() const override { return eSubOperation_Copying; } Index: src/libchcore/TSubTaskDelete.cpp =================================================================== diff -u -r89f857792bba8752de98ddd477949e45cef5ba5a -r3b320bc86d4e808c2f6a70c10bd5c9936102b301 --- src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision 89f857792bba8752de98ddd477949e45cef5ba5a) +++ src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision 3b320bc86d4e808c2f6a70c10bd5c9936102b301) @@ -57,6 +57,25 @@ m_tSubTaskStats.Clear(); } + void TSubTaskDelete::InitBeforeExec() + { + TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); + + file_count_t fcCount = rFilesCache.GetSize(); + if(fcCount == 0) + { + m_tSubTaskStats.SetCurrentPath(TString()); + return; + } + + file_count_t fcIndex = m_tSubTaskStats.GetCurrentIndex(); + if(fcIndex >= fcCount) + fcIndex = 0; + + TFileInfoPtr spFileInfo = rFilesCache.GetAt(fcIndex); + m_tSubTaskStats.SetCurrentPath(spFileInfo->GetFullFilePath().ToString()); + } + TSubTaskBase::ESubOperationResult TSubTaskDelete::Exec(const IFeedbackHandlerPtr& spFeedback) { TScopedRunningTimeTracker guard(m_tSubTaskStats); Index: src/libchcore/TSubTaskDelete.h =================================================================== diff -u -r25722a1d39e5d4bb49c5a60cbee3dda6c02cb193 -r3b320bc86d4e808c2f6a70c10bd5c9936102b301 --- src/libchcore/TSubTaskDelete.h (.../TSubTaskDelete.h) (revision 25722a1d39e5d4bb49c5a60cbee3dda6c02cb193) +++ src/libchcore/TSubTaskDelete.h (.../TSubTaskDelete.h) (revision 3b320bc86d4e808c2f6a70c10bd5c9936102b301) @@ -38,6 +38,7 @@ virtual void Reset(); + virtual void InitBeforeExec() override; virtual ESubOperationResult Exec(const IFeedbackHandlerPtr& spFeedbackHandler) override; virtual ESubOperationType GetSubOperationType() const override { return eSubOperation_Deleting; } Index: src/libchcore/TSubTaskFastMove.cpp =================================================================== diff -u -r2088b7e742e3b3817c2fe356166307622be31efb -r3b320bc86d4e808c2f6a70c10bd5c9936102b301 --- src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision 2088b7e742e3b3817c2fe356166307622be31efb) +++ src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision 3b320bc86d4e808c2f6a70c10bd5c9936102b301) @@ -59,6 +59,25 @@ m_tSubTaskStats.Clear(); } + void TSubTaskFastMove::InitBeforeExec() + { + TBasePathDataContainerPtr spBasePaths = GetContext().GetBasePaths(); + + file_count_t fcSize = spBasePaths->GetCount(); + file_count_t fcIndex = m_tSubTaskStats.GetCurrentIndex(); + + if(fcIndex >= fcSize) + fcIndex = 0; + + if(fcSize > 0) + { + TBasePathDataPtr spBasePath = spBasePaths->GetAt(fcIndex); + m_tSubTaskStats.SetCurrentPath(spBasePath->GetSrcPath().ToString()); + } + else + m_tSubTaskStats.SetCurrentPath(TString()); + } + TSubTaskFastMove::ESubOperationResult TSubTaskFastMove::Exec(const IFeedbackHandlerPtr& spFeedback) { TScopedRunningTimeTracker guard(m_tSubTaskStats); Index: src/libchcore/TSubTaskFastMove.h =================================================================== diff -u -r25722a1d39e5d4bb49c5a60cbee3dda6c02cb193 -r3b320bc86d4e808c2f6a70c10bd5c9936102b301 --- src/libchcore/TSubTaskFastMove.h (.../TSubTaskFastMove.h) (revision 25722a1d39e5d4bb49c5a60cbee3dda6c02cb193) +++ src/libchcore/TSubTaskFastMove.h (.../TSubTaskFastMove.h) (revision 3b320bc86d4e808c2f6a70c10bd5c9936102b301) @@ -43,6 +43,7 @@ virtual void Reset(); + virtual void InitBeforeExec() override; virtual ESubOperationResult Exec(const IFeedbackHandlerPtr& spFeedbackHandler) override; virtual ESubOperationType GetSubOperationType() const override { return eSubOperation_FastMove; } Index: src/libchcore/TSubTaskScanDirectory.cpp =================================================================== diff -u -r89f857792bba8752de98ddd477949e45cef5ba5a -r3b320bc86d4e808c2f6a70c10bd5c9936102b301 --- src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 89f857792bba8752de98ddd477949e45cef5ba5a) +++ src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 3b320bc86d4e808c2f6a70c10bd5c9936102b301) @@ -60,6 +60,25 @@ m_tSubTaskStats.Clear(); } + void TSubTaskScanDirectories::InitBeforeExec() + { + TBasePathDataContainerPtr spBasePaths = GetContext().GetBasePaths(); + + file_count_t fcSize = spBasePaths->GetCount(); + file_count_t fcIndex = m_tSubTaskStats.GetCurrentIndex(); + + if(fcIndex >= fcSize) + fcIndex = 0; + + if(fcSize > 0) + { + TBasePathDataPtr spBasePath = spBasePaths->GetAt(fcIndex); + m_tSubTaskStats.SetCurrentPath(spBasePath->GetSrcPath().ToString()); + } + else + m_tSubTaskStats.SetCurrentPath(TString()); + } + TSubTaskScanDirectories::ESubOperationResult TSubTaskScanDirectories::Exec(const IFeedbackHandlerPtr& spFeedback) { TScopedRunningTimeTracker guard(m_tSubTaskStats); Index: src/libchcore/TSubTaskScanDirectory.h =================================================================== diff -u -r25722a1d39e5d4bb49c5a60cbee3dda6c02cb193 -r3b320bc86d4e808c2f6a70c10bd5c9936102b301 --- src/libchcore/TSubTaskScanDirectory.h (.../TSubTaskScanDirectory.h) (revision 25722a1d39e5d4bb49c5a60cbee3dda6c02cb193) +++ src/libchcore/TSubTaskScanDirectory.h (.../TSubTaskScanDirectory.h) (revision 3b320bc86d4e808c2f6a70c10bd5c9936102b301) @@ -44,6 +44,7 @@ virtual void Reset(); + virtual void InitBeforeExec() override; virtual ESubOperationResult Exec(const IFeedbackHandlerPtr& spFeedbackHandler) override; virtual ESubOperationType GetSubOperationType() const override { return eSubOperation_Scanning; } Index: src/libchcore/TTask.cpp =================================================================== diff -u -r8592d6dcef30c8e4967ca4dcee37c1ca52afbf16 -r3b320bc86d4e808c2f6a70c10bd5c9936102b301 --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision 8592d6dcef30c8e4967ca4dcee37c1ca52afbf16) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision 3b320bc86d4e808c2f6a70c10bd5c9936102b301) @@ -526,7 +526,10 @@ // determine when to scan directories bool bReadTasksSize = GetTaskPropValue(m_tConfiguration); - // prepare context for subtasks + // initialize subtask array + m_tSubTasksArray.InitBeforeExec(); + + // exec the estimation subtasks if (bReadTasksSize) eResult = m_tSubTasksArray.Execute(spFeedbackHandler, true);