Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -ra476ced2f2235ee21c69176e88eba1cf7aea861f -rc66b22f786f8434075a09e92de52bba8a53a85db --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision a476ced2f2235ee21c69176e88eba1cf7aea861f) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision c66b22f786f8434075a09e92de52bba8a53a85db) @@ -90,9 +90,13 @@ // initialize stats if not resuming (when resuming we have already initialized // the stats once - it is being restored in Load() too). - if(!m_tSubTaskStats.IsInitialized()) - { + if (!m_tSubTaskStats.IsInitialized()) m_tSubTaskStats.Init(TBufferSizes::eBuffer_Default, rFilesCache.GetSize(), 0, rFilesCache.CalculateTotalSize(), rFilesCache.CalculatePartialSize(m_tSubTaskStats.GetCurrentIndex()), TString()); + else + { + _ASSERTE(rFilesCache.GetSize() == m_tSubTaskStats.GetTotalCount()); + if (rFilesCache.GetSize() != m_tSubTaskStats.GetTotalCount()) + THROW_CORE_EXCEPTION(eErr_InternalProblem); } // now it's time to check if there is enough space on destination device Index: src/libchcore/TSubTaskStatsInfo.cpp =================================================================== diff -u -ra476ced2f2235ee21c69176e88eba1cf7aea861f -rc66b22f786f8434075a09e92de52bba8a53a85db --- src/libchcore/TSubTaskStatsInfo.cpp (.../TSubTaskStatsInfo.cpp) (revision a476ced2f2235ee21c69176e88eba1cf7aea861f) +++ src/libchcore/TSubTaskStatsInfo.cpp (.../TSubTaskStatsInfo.cpp) (revision c66b22f786f8434075a09e92de52bba8a53a85db) @@ -148,6 +148,12 @@ THROW_CORE_EXCEPTION(eErr_InternalProblem); } +chcore::file_count_t TSubTaskStatsInfo::GetTotalCount() const +{ + boost::shared_lock lock(m_lock); + return m_fcTotalCount; +} + void TSubTaskStatsInfo::IncreaseProcessedSize(unsigned long long ullIncreaseBy) { boost::unique_lock lock(m_lock); Index: src/libchcore/TSubTaskStatsInfo.h =================================================================== diff -u -ra476ced2f2235ee21c69176e88eba1cf7aea861f -rc66b22f786f8434075a09e92de52bba8a53a85db --- src/libchcore/TSubTaskStatsInfo.h (.../TSubTaskStatsInfo.h) (revision a476ced2f2235ee21c69176e88eba1cf7aea861f) +++ src/libchcore/TSubTaskStatsInfo.h (.../TSubTaskStatsInfo.h) (revision c66b22f786f8434075a09e92de52bba8a53a85db) @@ -62,6 +62,7 @@ void SetProcessedCount(file_count_t fcIndex); void SetTotalCount(file_count_t fcCount); + file_count_t GetTotalCount() const; // size stats void IncreaseProcessedSize(unsigned long long ullIncreaseBy); Index: src/libchcore/TTask.cpp =================================================================== diff -u -r3045f3bb4e1fd76ea1fd3cd61d2fa8bf49771436 -rc66b22f786f8434075a09e92de52bba8a53a85db --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision 3045f3bb4e1fd76ea1fd3cd61d2fa8bf49771436) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision c66b22f786f8434075a09e92de52bba8a53a85db) @@ -188,10 +188,7 @@ try { if(bLogPathLoaded) - { - m_log.init(m_tBaseData.GetLogPath().ToString(), 262144, icpf::log_file::level_debug, false, false); - m_log.loge(szErr); - } + GetLog().loge(szErr); } catch(const std::exception&) { @@ -252,6 +249,8 @@ void TTask::BeginProcessing() { + GetLog().logi(_T("Requested task to begin processing")); + boost::unique_lock lock(m_lock); if(m_tBaseData.GetCurrentState() != eTaskState_LoadError) m_workerThread.StartThread(DelegateThreadProc, this, GetTaskPropValue(m_tConfiguration)); @@ -262,6 +261,7 @@ // the same as retry but less demanding if(GetTaskState() == eTaskState_Paused) { + GetLog().logi(_T("Requested task resume")); SetTaskState(eTaskState_Processing); BeginProcessing(); } @@ -286,6 +286,7 @@ void TTask::RestartProcessing() { + GetLog().logi(_T("Requested task restart")); KillThread(); SetTaskState(eTaskState_None); @@ -301,6 +302,7 @@ { if(GetTaskState() != eTaskState_Finished && GetTaskState() != eTaskState_Cancelled) { + GetLog().logi(_T("Requested task pause")); KillThread(); SetTaskState(eTaskState_Paused); } @@ -311,6 +313,7 @@ // change to ST_CANCELLED if(GetTaskState() != eTaskState_Finished) { + GetLog().logi(_T("Requested task cancel")); KillThread(); SetTaskState(eTaskState_Cancelled); } @@ -443,9 +446,9 @@ // return; // skips sleep and kill flag checking } + else + Sleep(50); // not to make it too hard for processor - Sleep(50); // not to make it too hard for processor - if(m_workerThread.KillRequested()) { // log @@ -649,4 +652,12 @@ return m_spSerializer; } +icpf::log_file& TTask::GetLog() +{ + if (!m_log.is_initialized()) + m_log.init(m_tBaseData.GetLogPath().ToString(), 262144, icpf::log_file::level_debug, false, false); + + return m_log; +} + END_CHCORE_NAMESPACE Index: src/libchcore/TTask.h =================================================================== diff -u -r7d59ab9183c933f2fc2682a95fb5d26cf2f952d7 -rc66b22f786f8434075a09e92de52bba8a53a85db --- src/libchcore/TTask.h (.../TTask.h) (revision 7d59ab9183c933f2fc2682a95fb5d26cf2f952d7) +++ src/libchcore/TTask.h (.../TTask.h) (revision c66b22f786f8434075a09e92de52bba8a53a85db) @@ -84,7 +84,9 @@ void SetTaskDefinition(const TTaskDefinition& rTaskDefinition); void SetLogPath(const TSmartPath& pathLog); + icpf::log_file& GetLog(); + // methods are called when task is being added or removed from the global task array /// Method is called when this task is being added to a TTaskManager object void OnRegisterTask();