From f29cf99431e65c7cadafad1d2afd9b7f55d6d460 Mon Sep 17 00:00:00 2001 From: "Thomas J. Moore" Date: Sat, 20 Feb 2016 15:01:00 -0600 Subject: [PATCH] Automatically create XML files (MD5sum cache) for manually downloaded files during status check if automatic creation enabled. --- src/downloader.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/downloader.cpp b/src/downloader.cpp index 9d6b077..419bab4 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -2876,23 +2876,35 @@ std::string Downloader::getLocalFileHash(const std::string& filepath, const std: else local_xml_file = config.sXMLDirectory + "/" + path.filename().string() + ".xml"; + if (config.bAutomaticXMLCreation && !boost::filesystem::exists(local_xml_file)) + { + std::string xml_directory = config.sXMLDirectory + "/" + gamename; + Util::createXML(filepath, config.iChunkSize, xml_directory); + } + if (boost::filesystem::exists(local_xml_file)) { TiXmlDocument local_xml; local_xml.LoadFile(local_xml_file.string()); TiXmlNode *fileNodeLocal = local_xml.FirstChild("file"); + if (!fileNodeLocal && config.bAutomaticXMLCreation) + { + std::string xml_directory = config.sXMLDirectory + "/" + gamename; + Util::createXML(filepath, config.iChunkSize, xml_directory); + local_xml.LoadFile(local_xml_file.string()); + fileNodeLocal = local_xml.FirstChild("file"); + } if (fileNodeLocal) { TiXmlElement *fileElemLocal = fileNodeLocal->ToElement(); localHash = fileElemLocal->Attribute("md5"); + return localHash; } } - else + + if (boost::filesystem::exists(path) && boost::filesystem::is_regular_file(path)) { - if (boost::filesystem::exists(path) && boost::filesystem::is_regular_file(path)) - { - localHash = Util::getFileHash(path.string(), RHASH_MD5); - } + localHash = Util::getFileHash(path.string(), RHASH_MD5); } return localHash; }