Added: Function to request status updates of specified paths.

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 13 years ago
parent 3d8be0c891
commit a665277784

@ -93,6 +93,7 @@ std::string getStatusFilePath(const std::string &path)
else else
{ {
nlerror("Path is not in database or pipeline"); 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::string dirPath = CPath::standardizePath(dir, true);
std::vector<std::string> dirContents; std::vector<std::string> dirContents;
@ -350,7 +351,8 @@ void updateDirectoryStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater,
if (CFile::isDirectory(subPath)) // if the file is a directory! 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 else
{ {
@ -376,6 +378,13 @@ void updateDirectoryStatus(CDatabaseStatus* ds, CDatabaseStatusUpdater &updater,
} /* anonymous namespace */ } /* anonymous namespace */
void CDatabaseStatus::updateDatabaseStatus(const CCallback<void> &callback) void CDatabaseStatus::updateDatabaseStatus(const CCallback<void> &callback)
{
std::vector<std::string> paths;
paths.push_back(g_DatabaseDirectory);
updateDatabaseStatus(callback, paths, true);
}
void CDatabaseStatus::updateDatabaseStatus(const CCallback<void> &callback, const std::vector<std::string> &paths, bool recurse)
{ {
CDatabaseStatusUpdater *updater = new CDatabaseStatusUpdater(); CDatabaseStatusUpdater *updater = new CDatabaseStatusUpdater();
updater->Callback = callback; updater->Callback = callback;
@ -385,10 +394,10 @@ void CDatabaseStatus::updateDatabaseStatus(const CCallback<void> &callback)
updater->CallbackCalled = false; updater->CallbackCalled = false;
nlinfo("Starting iteration through database, queueing file status updates."); nlinfo("Starting iteration through database, queueing file status updates.");
// recursive loop for (std::vector<std::string>::const_iterator it = paths.begin(), end = paths.end(); it != end; ++it)
updateDirectoryStatus(this, *updater, g_DatabaseDirectory); updateDirectoryStatus(this, *updater, unMacroPath(*it), recurse);
nlinfo("Iteration through database, queueing file status updates complete."); nlinfo("Iteration through database, queueing file status updates complete.");
bool done = false; bool done = false;

@ -30,6 +30,7 @@
#include <nel/misc/types_nl.h> #include <nel/misc/types_nl.h>
// STL includes // STL includes
#include <string>
#include <vector> #include <vector>
// NeL includes // NeL includes
@ -105,8 +106,10 @@ public:
bool getFileStatus(CFileStatus &fileStatus, const std::string &filePath) const; 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. /// 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); 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<void> &callback); void updateDatabaseStatus(const CCallback<void> &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<void> &callback, const std::vector<std::string> &paths, bool recurse = false);
void getFileErrors(CFileErrors &fileErrors, const std::string &filePath, uint32 newerThan = 0) const; void getFileErrors(CFileErrors &fileErrors, const std::string &filePath, uint32 newerThan = 0) const;
void addFileError(const std::string &filePath, const CFileError &fileError); void addFileError(const std::string &filePath, const CFileError &fileError);

Loading…
Cancel
Save