diff --git a/code/nel/tools/pipeline/service/database_status.cpp b/code/nel/tools/pipeline/service/database_status.cpp index f622e92d2..eab4ef519 100644 --- a/code/nel/tools/pipeline/service/database_status.cpp +++ b/code/nel/tools/pipeline/service/database_status.cpp @@ -245,7 +245,7 @@ bool CDatabaseStatus::getFileStatus(std::map &fileStat std::string &dirPath = path; std::vector dirContents; - CPath::getPathContent(dirPath, false, true, true, dirContents); + CPath::getPathContent(dirPath, false, false, true, dirContents); // get only files, no dirs for (std::vector::iterator it = dirContents.begin(), end = dirContents.end(); it != end; ++it) { @@ -253,7 +253,11 @@ bool CDatabaseStatus::getFileStatus(std::map &fileStat CFileStatus fs; if (!getFileStatus(fs, subPath)) - return false; // bad status, data corruption // TODO_PROCESS_ERROR + { + // bad status, data corruption // TODO_PROCESS_ERROR + nlwarning("Invalid status for '%s'!", subPath.c_str()); + return false; + } fileStatusMap[subPath] = fs; // i'll assume macropath might be easiest // TODO_PROCESS_ERROR_EXIT @@ -297,7 +301,11 @@ bool CDatabaseStatus::getFileStatus(std::map &fileStat { CFileStatus fs; if (!getFileStatus(fs, path)) - return false; // bad status, data corruption // TODO_PROCESS_ERROR + { + // bad status, data corruption // TODO_PROCESS_ERROR + nlwarning("Invalid status for '%s'!", path.c_str()); + return false; + } fileStatusMap[path] = fs; // i'll assume macropath might be easiest } } diff --git a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp index 28191ea3e..a7af7857a 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp @@ -40,6 +40,7 @@ #include "../plugin_library/process_info.h" #include "pipeline_workspace.h" #include "pipeline_process_impl.h" +#include "database_status.h" using namespace std; using namespace NLMISC; @@ -221,14 +222,18 @@ public: protected: NLMISC_COMMAND_HANDLER_TABLE_EXTEND_BEGIN(CModulePipelineSlave, CModuleBase) NLMISC_COMMAND_HANDLER_ADD(CModulePipelineSlave, testUpdateDatabaseStatus, "Test master request for database status update on dependencies", " ") + NLMISC_COMMAND_HANDLER_ADD(CModulePipelineSlave, testGetFileStatus, "Test reading of file status from slave on dependencies", " ") NLMISC_COMMAND_HANDLER_TABLE_END NLMISC_CLASS_COMMAND_DECL(testUpdateDatabaseStatus); + NLMISC_CLASS_COMMAND_DECL(testGetFileStatus); }; /* class CModulePipelineSlave */ //return PIPELINE::tryRunnableTask(stateName, task); +/////////////////////////////////////////////////////////////////////// + namespace { class CTestUpdateDatabaseStatusCommand : public NLMISC::IRunnable @@ -315,6 +320,108 @@ NLMISC_CLASS_COMMAND_IMPL(CModulePipelineSlave, testUpdateDatabaseStatus) return true; } +/////////////////////////////////////////////////////////////////////// + +namespace { + +class CTestGetFileStatusCommand : public NLMISC::IRunnable +{ +public: + NLMISC::CLog *Log; + std::string Project; + std::string Process; + CModulePipelineSlave *Slave; + + virtual void getName(std::string &result) const + { result = "CTestGetFileStatusCommand"; } + + virtual void run() + { + // Slave->m_TestCommand = true; + + // std::string tempDirectory = PIPELINE::IPipelineProcess::getInstance()->getTempDirectory(); + std::vector plugins; + PIPELINE::g_PipelineWorkspace->getProcessPlugins(plugins, Process); + PIPELINE::CPipelineProject *project = PIPELINE::g_PipelineWorkspace->getProject(Project); + + std::vector dependPaths; + + if (project) + { + std::vector result; + PIPELINE::IPipelineProcess *pipelineProcess = new PIPELINE::CPipelineProcessImpl(project); + for (std::vector::iterator plugin_it = plugins.begin(), plugin_end = plugins.end(); plugin_it != plugin_end; ++plugin_it) + { + switch (plugin_it->InfoType) + { + case PIPELINE::PLUGIN_REGISTERED_CLASS: + { + PIPELINE::IProcessInfo *processInfo = static_cast(NLMISC::CClassRegistry::create(plugin_it->Info)); + processInfo->setPipelineProcess(pipelineProcess); + processInfo->getDependentDirectories(result); + for (std::vector::iterator it = result.begin(), end = result.end(); it != end; ++it) + dependPaths.push_back(*it); + result.clear(); + processInfo->getDependentFiles(result); + for (std::vector::iterator it = result.begin(), end = result.end(); it != end; ++it) + dependPaths.push_back(*it); + result.clear(); + } + break; + default: + nlwarning("Not implemented"); + break; + } + } + } + else + { + Log->displayNL("Project '%s' does not exist", Project.c_str()); + } + + // Slave->m_Master->getFileStatusByVector(Slave); + std::map fileStatusMap; + std::map fileRemoveMap; + if (g_DatabaseStatus->getFileStatus(fileStatusMap, fileRemoveMap, dependPaths)) + Log->displayNL("File status completed successfully"); + else + Log->displayNL("File status failed"); + Log->displayNL("Found %i file statuses, %i removes", fileStatusMap.size(), fileRemoveMap.size()); + + delete this; + + endedRunnableTask(); + } +}; + +} /* anonymous namespace */ + +NLMISC_CLASS_COMMAND_IMPL(CModulePipelineSlave, testGetFileStatus) +{ + // EXAMPLE USAGE: slave.testGetFileStatus common_interface Interface + + if (args.size() != 2) return false; + + PIPELINE::CPipelineProject *project = PIPELINE::g_PipelineWorkspace->getProject(args[0]); + if (!project) + { + log.displayNL("Project '%s' does not exist", args[0].c_str()); + return false; + } + + CTestGetFileStatusCommand *runnableCommand = new CTestGetFileStatusCommand(); + runnableCommand->Log = &log; + runnableCommand->Project = args[0]; + runnableCommand->Process = args[1]; + runnableCommand->Slave = this; + + if (!tryRunnableTask("SLAVE_TEST_GET_F_STATUS", runnableCommand)) + { log.displayNL("BUSY"); delete runnableCommand; return false; } + return true; +} + +/////////////////////////////////////////////////////////////////////// + void module_pipeline_slave_forceLink() { } NLNET_REGISTER_MODULE_FACTORY(CModulePipelineSlave, "ModulePipelineSlave");