Index: src/libchcore/ErrorCodes.h =================================================================== diff -u -rcdb4c898156398dd4f4bf8abd7c854eff42f6ae2 -r2e384de25de613cb582a966df7d1cb9468f1c825 --- src/libchcore/ErrorCodes.h (.../ErrorCodes.h) (revision cdb4c898156398dd4f4bf8abd7c854eff42f6ae2) +++ src/libchcore/ErrorCodes.h (.../ErrorCodes.h) (revision 2e384de25de613cb582a966df7d1cb9468f1c825) @@ -58,6 +58,7 @@ // Task definition errors (2000+) eErr_UnsupportedVersion = 2000, eErr_MissingXmlData = 2001, + eErr_TaskAlreadyExists = 2002, // Serialization errors (2500+) eErr_CannotReadArchive = 2500, Index: src/libchcore/TTask.cpp =================================================================== diff -u -r671f4b1792a20d98b186f4e0a9cc6a620dede019 -r2e384de25de613cb582a966df7d1cb9468f1c825 --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision 671f4b1792a20d98b186f4e0a9cc6a620dede019) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision 2e384de25de613cb582a966df7d1cb9468f1c825) @@ -648,6 +648,11 @@ return m_tBaseData.GetLogPath(); } +chcore::TString chcore::TTask::GetTaskName() const +{ + return m_tBaseData.GetTaskName(); +} + void TTask::SetLogPath(const TSmartPath& pathLog) { m_tBaseData.SetLogPath(pathLog); Index: src/libchcore/TTask.h =================================================================== diff -u -rc66b22f786f8434075a09e92de52bba8a53a85db -r2e384de25de613cb582a966df7d1cb9468f1c825 --- src/libchcore/TTask.h (.../TTask.h) (revision c66b22f786f8434075a09e92de52bba8a53a85db) +++ src/libchcore/TTask.h (.../TTask.h) (revision 2e384de25de613cb582a966df7d1cb9468f1c825) @@ -60,6 +60,7 @@ void GetBufferSizes(TBufferSizes& bsSizes); TSmartPath GetLogPath() const; + TString GetTaskName() const; // thread void SetPriority(int nPriority); @@ -86,7 +87,6 @@ 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(); Index: src/libchcore/TTaskDefinition.cpp =================================================================== diff -u -r503a68180cbb933c97e9af965744bf106994c05a -r2e384de25de613cb582a966df7d1cb9468f1c825 --- src/libchcore/TTaskDefinition.cpp (.../TTaskDefinition.cpp) (revision 503a68180cbb933c97e9af965744bf106994c05a) +++ src/libchcore/TTaskDefinition.cpp (.../TTaskDefinition.cpp) (revision 2e384de25de613cb582a966df7d1cb9468f1c825) @@ -188,16 +188,13 @@ m_bModified = false; // get information from config file - // task unique id - use if provided, generate otherwise - if (!GetConfigValue(rDataSrc, _T("TaskDefinition.UniqueID"), m_strTaskName) || m_strTaskName.IsEmpty()) - { - boost::uuids::random_generator gen; - boost::uuids::uuid u = gen(); - m_strTaskName = boost::lexical_cast(u).c_str(); + // NOTE: task unique id is not read from the config by design; + // by using the value, CH tried to re-use the task DB causing problems. + // So now, always a new identifier is generated. + boost::uuids::random_generator gen; + boost::uuids::uuid u = gen(); + m_strTaskName = boost::lexical_cast(u).c_str(); - m_bModified = true; - } - // basic information // source paths to be processed if (!GetConfigValue(rDataSrc, _T("TaskDefinition.SourcePaths.Path"), m_vSourcePaths) || m_vSourcePaths.IsEmpty()) @@ -267,7 +264,8 @@ { // get information from config file // task unique id - use if provided, generate otherwise - SetConfigValue(rConfig, _T("TaskDefinition.UniqueID"), m_strTaskName); + // NOTE: not storing the task ID is by design. Loading same task twice caused problems + // when importing and was disabled. With that, storing was no longer needed. // basic information SetConfigValue(rConfig, _T("TaskDefinition.SourcePaths.Path"), m_vSourcePaths); Index: src/libchcore/TTaskManager.cpp =================================================================== diff -u -rcdb4c898156398dd4f4bf8abd7c854eff42f6ae2 -r2e384de25de613cb582a966df7d1cb9468f1c825 --- src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision cdb4c898156398dd4f4bf8abd7c854eff42f6ae2) +++ src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision 2e384de25de613cb582a966df7d1cb9468f1c825) @@ -73,6 +73,15 @@ TTaskDefinition tTaskDefinition; tTaskDefinition.Load(strTaskPath); + for (size_t stIndex = 0; stIndex < m_tTasks.GetCount(); ++stIndex) + { + const TTaskInfoEntry& rEntry = m_tTasks.GetAt(stIndex); + TTaskPtr spTask = rEntry.GetTask(); + + if (spTask->GetTaskName() == tTaskDefinition.GetTaskName()) + THROW_CORE_EXCEPTION(eErr_TaskAlreadyExists); + } + return CreateTask(tTaskDefinition); }