From fffba58a570e639847300c73362a9b37fc4ae954 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 1 Aug 2012 15:12:59 +0200 Subject: [PATCH] Added: #1440 Additional sanity checks on removed file listing --HG-- branch : build_pipeline_v3 --- .../pipeline/service/database_status.cpp | 30 ++++++++++++++----- .../tools/pipeline/service/database_status.h | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/code/nel/tools/pipeline/service/database_status.cpp b/code/nel/tools/pipeline/service/database_status.cpp index 611e99531..dda84a3cb 100644 --- a/code/nel/tools/pipeline/service/database_status.cpp +++ b/code/nel/tools/pipeline/service/database_status.cpp @@ -194,7 +194,7 @@ bool CDatabaseStatus::getFileStatus(std::map &fileStat return true; } -void CDatabaseStatus::getRemoved(std::map &fileRemoveMap, const std::vector &paths) +bool CDatabaseStatus::getRemoved(std::map &fileRemoveMap, const std::vector &paths) { for (std::vector::const_iterator it = paths.begin(), end = paths.end(); it != end; ++it) { @@ -249,9 +249,15 @@ void CDatabaseStatus::getRemoved(std::map &fileRemoveM nldebug("Found remove meta for file '%s'!", subPathOrig.c_str()); // Read the removed tag. - std::string removedTagFile = dirPathMeta + subPathFilename + PIPELINE_DATABASE_REMOVE_SUFFIX; + std::string removeTagFile = dirPathMeta + subPathFilename + PIPELINE_DATABASE_REMOVE_SUFFIX; + std::string statusTagFile = dirPathMeta + subPathFilename + PIPELINE_DATABASE_STATUS_SUFFIX; + if (CFile::isExists(statusTagFile)) + { + nlwarning("Removed file has status"); + return false; + } CFileRemove fr; - CIFile ifr(removedTagFile, false); + CIFile ifr(removeTagFile, false); fr.serial(ifr); ifr.close(); @@ -260,7 +266,7 @@ void CDatabaseStatus::getRemoved(std::map &fileRemoveM // TODO_PROCESS_ERROR_EXIT if (g_IsExiting) - return; + return false; } } } @@ -269,11 +275,17 @@ void CDatabaseStatus::getRemoved(std::map &fileRemoveM // TODO_PROCESS_WARNING nlwarning("Requesting information on file or directory '%s' that does not exist!", path.c_str()); CFileRemove fr; - std::string removedTagFile = CWorkspaceStorage::getMetaFilePath(path, PIPELINE_DATABASE_REMOVE_SUFFIX); - if (CFile::isExists(removedTagFile)) + std::string removeTagFile = CWorkspaceStorage::getMetaFilePath(path, PIPELINE_DATABASE_REMOVE_SUFFIX); + std::string statusTagFile = CWorkspaceStorage::getMetaFilePath(path, PIPELINE_DATABASE_RESULT_SUFFIX); + if (CFile::isExists(statusTagFile)) + { + nlwarning("Not existing file has status"); + return false; + } + if (CFile::isExists(removeTagFile)) { // file existed before - CIFile ifr(removedTagFile, false); + CIFile ifr(removeTagFile, false); fr.serial(ifr); ifr.close(); } @@ -287,8 +299,10 @@ void CDatabaseStatus::getRemoved(std::map &fileRemoveM // TODO_PROCESS_ERROR_EXIT if (g_IsExiting) - return; + return false; } + + return true; } namespace { diff --git a/code/nel/tools/pipeline/service/database_status.h b/code/nel/tools/pipeline/service/database_status.h index 5a675e185..d762cfaf3 100644 --- a/code/nel/tools/pipeline/service/database_status.h +++ b/code/nel/tools/pipeline/service/database_status.h @@ -78,7 +78,7 @@ public: /// Gets the last file statuses of given paths in a map. Directories are scanned for files, non recursively. Returns false if one of the statuses is bad (not updated; file changed inbetween). Considered as build error. bool getFileStatus(std::map &fileStatusMap, std::map &fileRemoveMap, const std::vector &paths); /// Gets all removed files - void getRemoved(std::map &fileRemoveMap, const std::vector &paths); + bool getRemoved(std::map &fileRemoveMap, const std::vector &paths); void getFileErrors(CFileErrors &fileErrors, const std::string &filePath, uint32 newerThan = 0) const; void addFileError(const std::string &filePath, const CFileError &fileError);