From a665277784e6c3d1a13a8d199dc5a0325dea71cd Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 19 Feb 2012 12:52:26 +0100 Subject: [PATCH] Added: Function to request status updates of specified paths. --HG-- branch : build_pipeline_v3 --- .../pipeline_service/database_status.cpp | 21 +++++++++++++------ .../pipeline_service/database_status.h | 5 ++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/code/nel/tools/pipeline/pipeline_service/database_status.cpp b/code/nel/tools/pipeline/pipeline_service/database_status.cpp index 5e056ac61..806883c51 100644 --- a/code/nel/tools/pipeline/pipeline_service/database_status.cpp +++ b/code/nel/tools/pipeline/pipeline_service/database_status.cpp @@ -93,6 +93,7 @@ std::string getStatusFilePath(const std::string &path) else { nlerror("Path is not in database or pipeline"); + return path + PIPELINE_DATABASE_STATUS_SUFFIX; } } @@ -337,7 +338,7 @@ public: } }; -void updateDirectoryStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater, const std::string &dir) +void updateDirectoryStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater, const std::string &dir, bool recurse) { std::string dirPath = CPath::standardizePath(dir, true); std::vector dirContents; @@ -350,7 +351,8 @@ void updateDirectoryStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater, if (CFile::isDirectory(subPath)) // if the file is a directory! { - updateDirectoryStatus(ds, updater, subPath); + if (recurse) + updateDirectoryStatus(ds, updater, subPath, recurse); // lol recurse is true anyway } else { @@ -376,6 +378,13 @@ void updateDirectoryStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater, } /* anonymous namespace */ void CDatabaseStatus::updateDatabaseStatus(const CCallback &callback) +{ + std::vector paths; + paths.push_back(g_DatabaseDirectory); + updateDatabaseStatus(callback, paths, true); +} + +void CDatabaseStatus::updateDatabaseStatus(const CCallback &callback, const std::vector &paths, bool recurse) { CDatabaseStatusUpdater *updater = new CDatabaseStatusUpdater(); updater->Callback = callback; @@ -385,10 +394,10 @@ void CDatabaseStatus::updateDatabaseStatus(const CCallback &callback) updater->CallbackCalled = false; nlinfo("Starting iteration through database, queueing file status updates."); - - // recursive loop - updateDirectoryStatus(this, *updater, g_DatabaseDirectory); - + + for (std::vector::const_iterator it = paths.begin(), end = paths.end(); it != end; ++it) + updateDirectoryStatus(this, *updater, unMacroPath(*it), recurse); + nlinfo("Iteration through database, queueing file status updates complete."); bool done = false; diff --git a/code/nel/tools/pipeline/pipeline_service/database_status.h b/code/nel/tools/pipeline/pipeline_service/database_status.h index d935c34c4..bc96eb6de 100644 --- a/code/nel/tools/pipeline/pipeline_service/database_status.h +++ b/code/nel/tools/pipeline/pipeline_service/database_status.h @@ -30,6 +30,7 @@ #include // STL includes +#include #include // NeL includes @@ -105,8 +106,10 @@ public: bool getFileStatus(CFileStatus &fileStatus, const std::string &filePath) const; /// Updates the file status asynchronously. The new file status is broadcast to clients and slaves afterwards. Warning: If g_IsExiting during callback then update likely did not happen. NLMISC::IRunnable *updateFileStatus(const TFileStatusCallback &callback, const std::string &filePath); - /// Forces an update of the complete database status. Warning: If g_IsExiting during callback then update is incomplete. + /// Runs an update of the complete {{DatabaseDirectory}} status. Warning: If g_IsExiting during callback then update is incomplete. Callback is always called when done (or failed). void updateDatabaseStatus(const CCallback &callback); + /// Runs an update of the file status of given paths. Warning: If g_IsExiting during callback then update is incomplete. Callback is always called when done (or failed). Do NOT use recurse, please. Recurse directories beforehand. Paths may contain db and pl macros. + void updateDatabaseStatus(const CCallback &callback, const std::vector &paths, bool recurse = false); void getFileErrors(CFileErrors &fileErrors, const std::string &filePath, uint32 newerThan = 0) const; void addFileError(const std::string &filePath, const CFileError &fileError);