From 959d43bb1c76c2600827b7bf3d5a2b295743b495 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 1 Aug 2012 15:05:24 +0200 Subject: [PATCH] Added: #1440 Function to list known removed files --HG-- branch : build_pipeline_v3 --- .../pipeline/service/database_status.cpp | 99 +++++++++++++++++++ .../tools/pipeline/service/database_status.h | 4 +- 2 files changed, 102 insertions(+), 1 deletion(-) diff --git a/code/nel/tools/pipeline/service/database_status.cpp b/code/nel/tools/pipeline/service/database_status.cpp index 04bd3380c..611e99531 100644 --- a/code/nel/tools/pipeline/service/database_status.cpp +++ b/code/nel/tools/pipeline/service/database_status.cpp @@ -77,6 +77,8 @@ bool CDatabaseStatus::getFileStatus(CFileStatus &fileStatus, const std::string & bool CDatabaseStatus::getFileStatus(std::map &fileStatusMap, std::map &fileRemoveMap, const std::vector &paths) { + nlassert(false); // not used + // ARE THE PATHS UNMACRO'D OR NOT??? // nlassert(false); // i don't think this is used? (yet?) (maybe for slave?) @@ -192,6 +194,103 @@ bool CDatabaseStatus::getFileStatus(std::map &fileStat return true; } +void CDatabaseStatus::getRemoved(std::map &fileRemoveMap, const std::vector &paths) +{ + for (std::vector::const_iterator it = paths.begin(), end = paths.end(); it != end; ++it) + { + const std::string ¯oPath = *it; + std::string path = unMacroPath(macroPath); + + if (CFile::isExists(path)) + { + if (CFile::isDirectory(path)) // perhaps it is possible to check only on / assuming it's properly formatted!! + { + nlassert(path.find_last_of('/') == path.size() - 1); // ensure sanity + + // std::string dirPath = standardizePath(path, true); + std::string &dirPath = path; + /*std::vector 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) + { + const std::string &subPath = *it; + + CFileStatus fs; + if (!getFileStatus(fs, subPath)) + { + // bad status, data corruption // TODO_PROCESS_ERROR + nlwarning("Invalid status for '%s'!", subPath.c_str()); + return; + } + fileStatusMap[subPath] = fs; // i'll assume macropath might be easiest + + // TODO_PROCESS_ERROR_EXIT + if (g_IsExiting) + return; + }*/ + + std::string dirPathMeta = CWorkspaceStorage::getMetaDirectoryPath(dirPath); + std::vector dirContentsMeta; + + CPath::getPathContent(dirPathMeta, false, false, true, dirContentsMeta); + + for (std::vector::iterator it = dirContentsMeta.begin(), end = dirContentsMeta.end(); it != end; ++it) + { + const std::string &subPath = *it; + + std::string::size_type removePos = subPath.find(PIPELINE_DATABASE_REMOVE_SUFFIX); + + if (removePos != std::string::npos) + { + std::string subPathFilename = CFile::getFilename(subPath.substr(0, removePos)); + std::string subPathOrig = dirPath + subPathFilename; + + nldebug("Found remove meta for file '%s'!", subPathOrig.c_str()); + // Read the removed tag. + std::string removedTagFile = dirPathMeta + subPathFilename + PIPELINE_DATABASE_REMOVE_SUFFIX; + CFileRemove fr; + CIFile ifr(removedTagFile, false); + fr.serial(ifr); + ifr.close(); + + fileRemoveMap[subPathOrig] = fr; + } + + // TODO_PROCESS_ERROR_EXIT + if (g_IsExiting) + return; + } + } + } + else + { + // 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)) + { + // file existed before + CIFile ifr(removedTagFile, false); + fr.serial(ifr); + ifr.close(); + } + else + { + // file never existed or is directory + fr.Lost = 0; + } + fileRemoveMap[path] = fr; + } + + // TODO_PROCESS_ERROR_EXIT + if (g_IsExiting) + return; + } +} + namespace { class CUpdateFileStatus : public IRunnable diff --git a/code/nel/tools/pipeline/service/database_status.h b/code/nel/tools/pipeline/service/database_status.h index baa44043b..5a675e185 100644 --- a/code/nel/tools/pipeline/service/database_status.h +++ b/code/nel/tools/pipeline/service/database_status.h @@ -77,7 +77,9 @@ public: void updateDatabaseStatus(const CCallback &callback, const TFileStatusCallback &fileStatusCallback, const std::vector &paths, bool wait = false, bool recurse = false); /// 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); + void getFileErrors(CFileErrors &fileErrors, const std::string &filePath, uint32 newerThan = 0) const; void addFileError(const std::string &filePath, const CFileError &fileError);