From 31ebaee54ca1078d021f7ba300d8ff1888cfd235 Mon Sep 17 00:00:00 2001 From: Sude Date: Fri, 15 Jul 2016 18:33:03 +0300 Subject: [PATCH] Fix issue with some GOG XML data files Some GOG XML data files contain additional nodes/elements that were not handled properly and caused issues. We only care about the "chunk" elements so lets ignore all other xml elements. --- src/downloader.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/downloader.cpp b/src/downloader.cpp index 052d6fd..bbb05c2 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -1374,16 +1374,15 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath, std::stringstream(fileElem->Attribute("total_size")) >> filesize; //Iterate through all chunk nodes - tinyxml2::XMLNode *chunkNode = fileElem->FirstChild(); - while (chunkNode) + tinyxml2::XMLElement *chunkElem = fileElem->FirstChildElement("chunk"); + while (chunkElem) { - tinyxml2::XMLElement *chunkElem = chunkNode->ToElement(); std::stringstream(chunkElem->Attribute("from")) >> from_offset; std::stringstream(chunkElem->Attribute("to")) >> to_offset; chunk_from.push_back(from_offset); chunk_to.push_back(to_offset); chunk_hash.push_back(chunkElem->GetText()); - chunkNode = chunkNode->NextSibling(); + chunkElem = chunkElem->NextSiblingElement("chunk"); } std::cout << "XML: Parsing finished" << std::endl << std::endl