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.
This commit is contained in:
Sude 2016-07-15 18:33:03 +03:00
parent 116f9d88f2
commit 31ebaee54c

View File

@ -1374,16 +1374,15 @@ int Downloader::repairFile(const std::string& url, const std::string& filepath,
std::stringstream(fileElem->Attribute("total_size")) >> filesize; std::stringstream(fileElem->Attribute("total_size")) >> filesize;
//Iterate through all chunk nodes //Iterate through all chunk nodes
tinyxml2::XMLNode *chunkNode = fileElem->FirstChild(); tinyxml2::XMLElement *chunkElem = fileElem->FirstChildElement("chunk");
while (chunkNode) while (chunkElem)
{ {
tinyxml2::XMLElement *chunkElem = chunkNode->ToElement();
std::stringstream(chunkElem->Attribute("from")) >> from_offset; std::stringstream(chunkElem->Attribute("from")) >> from_offset;
std::stringstream(chunkElem->Attribute("to")) >> to_offset; std::stringstream(chunkElem->Attribute("to")) >> to_offset;
chunk_from.push_back(from_offset); chunk_from.push_back(from_offset);
chunk_to.push_back(to_offset); chunk_to.push_back(to_offset);
chunk_hash.push_back(chunkElem->GetText()); chunk_hash.push_back(chunkElem->GetText());
chunkNode = chunkNode->NextSibling(); chunkElem = chunkElem->NextSiblingElement("chunk");
} }
std::cout << "XML: Parsing finished" << std::endl << std::endl std::cout << "XML: Parsing finished" << std::endl << std::endl