From 81b8f66587f4f04c8c5db565dd6380ee692d7539 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Fri, 29 Mar 2024 01:28:24 -0600 Subject: Fixed detection on multiple export formats --- src/Companion.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/Companion.cpp') diff --git a/src/Companion.cpp b/src/Companion.cpp index 40870c2..f3b782f 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -418,13 +418,14 @@ std::string ExportTypeToString(ExportType type) { bool Companion::NodeHasChanges(const std::string& path) { - if(this->gConfig.exporterType == ExportType::Modding) { + if(this->gConfig.modding) { return true; } std::ifstream yaml(path); const std::vector data = std::vector(std::istreambuf_iterator( yaml ), {}); this->gCurrentHash = CalculateHash(data); + bool needsInit = true; if(this->gHashNode[path]) { auto entry = GetSafeNode(this->gHashNode, path); @@ -432,17 +433,22 @@ bool Companion::NodeHasChanges(const std::string& path) { auto modes = GetSafeNode(entry, "extracted"); auto extracted = GetSafeNode(modes, ExportTypeToString(this->gConfig.exporterType)); - if(hash == this->gCurrentHash && extracted) { - SPDLOG_INFO("Skipping {} as it has not changed", path); - return false; + if(hash == this->gCurrentHash) { + needsInit = false; + if(extracted) { + SPDLOG_INFO("Skipping {} as it has not changed", path); + return false; + } } } - this->gHashNode[path] = YAML::Node(); - this->gHashNode[path]["hash"] = this->gCurrentHash; - this->gHashNode[path]["extracted"] = YAML::Node(); - for(size_t m = 0; m < static_cast(ExportType::Modding); m++) { - this->gHashNode[path]["extracted"][ExportTypeToString(static_cast(m))] = false; + if(needsInit) { + this->gHashNode[path] = YAML::Node(); + this->gHashNode[path]["hash"] = this->gCurrentHash; + this->gHashNode[path]["extracted"] = YAML::Node(); + for(size_t m = 0; m <= static_cast(ExportType::Modding); m++) { + this->gHashNode[path]["extracted"][ExportTypeToString(static_cast(m))] = false; + } } return true; -- cgit v1.2.3