diff --git a/include/config.h b/include/config.h index 9385b9e..9ac33aa 100644 --- a/include/config.h +++ b/include/config.h @@ -249,6 +249,7 @@ class Config #ifdef USE_QT_GUI_LOGIN bool bEnableLoginGUI; #endif + bool bUseFastCheck; // Cache bool bUseCache; diff --git a/include/util.h b/include/util.h index 769b591..81a568f 100644 --- a/include/util.h +++ b/include/util.h @@ -79,7 +79,7 @@ namespace Util unsigned int getOptionValue(const std::string& str, const std::vector& options, const bool& bAllowStringToIntConversion = true); std::string getOptionNameString(const unsigned int& value, const std::vector& options); void parseOptionString(const std::string &option_string, std::vector &priority, unsigned int &type, const std::vector& options); - std::string getLocalFileHash(const std::string& xml_dir, const std::string& filepath, const std::string& gamename = std::string()); + std::string getLocalFileHash(const std::string& xml_dir, const std::string& filepath, const std::string& gamename = std::string(), const bool& useFastCheck = true); void shortenStringToTerminalWidth(std::string& str); std::string getJsonUIntValueAsString(const Json::Value& json); std::string getStrippedString(std::string str); diff --git a/main.cpp b/main.cpp index c946f50..8ead453 100644 --- a/main.cpp +++ b/main.cpp @@ -185,6 +185,7 @@ int main(int argc, char *argv[]) bool bNoPlatformDetection = false; bool bNoGalaxyDependencies = false; bool bUseDLCList = false; + bool bNoFastStatusCheck = false; std::string sInstallerPlatform; std::string sInstallerLanguage; std::string sIncludeOptions; @@ -209,7 +210,7 @@ int main(int argc, char *argv[]) ("updated", bpo::value(&Globals::globalConfig.bUpdated)->zero_tokens()->default_value(false), "List/download only games with update flag set") ("clear-update-flags", bpo::value(&bClearUpdateNotifications)->zero_tokens()->default_value(false), "Clear update notification flags") ("check-orphans", bpo::value(&Globals::globalConfig.sOrphanRegex)->implicit_value(""), check_orphans_text.c_str()) - ("status", bpo::value(&Globals::globalConfig.bCheckStatus)->zero_tokens()->default_value(false), "Show status of files\n\nOutput format:\nstatuscode gamename filename filesize filehash\n\nStatus codes:\nOK - File is OK\nND - File is not downloaded\nMD5 - MD5 mismatch, different version\nFS - File size mismatch, incomplete download") + ("status", bpo::value(&Globals::globalConfig.bCheckStatus)->zero_tokens()->default_value(false), "Show status of files\n\nOutput format:\nstatuscode gamename filename filesize filehash\n\nStatus codes:\nOK - File is OK\nND - File is not downloaded\nMD5 - MD5 mismatch, different version\nFS - File size mismatch, incomplete download\n\nSee also --no-fast-status-check option") ("save-config", bpo::value(&Globals::globalConfig.bSaveConfig)->zero_tokens()->default_value(false), "Create config file with current settings") ("reset-config", bpo::value(&Globals::globalConfig.bResetConfig)->zero_tokens()->default_value(false), "Reset config settings to default") ("report", bpo::value(&Globals::globalConfig.sReportFilePath)->implicit_value("lgogdownloader-report.log"), "Save report of downloaded/repaired files to specified file\nDefault filename: lgogdownloader-report.log") @@ -275,6 +276,7 @@ int main(int argc, char *argv[]) ("size-only", bpo::value(&Globals::globalConfig.bSizeOnly)->zero_tokens()->default_value(false), "Don't check the hashes of the files whose size matches that on the server") ("verbosity", bpo::value(&Globals::globalConfig.iMsgLevel)->default_value(0), "Set message verbosity level\n -1 = Less verbose\n 0 = Default\n 1 = Verbose\n 2 = Debug") ("check-free-space", bpo::value(&Globals::globalConfig.dlConf.bFreeSpaceCheck)->zero_tokens()->default_value(false), "Check for available free space before starting download") + ("no-fast-status-check", bpo::value(&bNoFastStatusCheck)->zero_tokens()->default_value(false), "Don't use fast status check.\nMakes --status much slower but able to catch corrupted files by calculating local file hash for all files.") ; options_cli_no_cfg_hidden.add_options() @@ -515,6 +517,7 @@ int main(int argc, char *argv[]) Globals::globalConfig.dirConf.bSubDirectories = !bNoSubDirectories; Globals::globalConfig.bPlatformDetection = !bNoPlatformDetection; Globals::globalConfig.dlConf.bGalaxyDependencies = !bNoGalaxyDependencies; + Globals::globalConfig.bUseFastCheck = !bNoFastStatusCheck; for (auto i = unrecognized_options_cli.begin(); i != unrecognized_options_cli.end(); ++i) if (i->compare(0, GlobalConstants::PROTOCOL_PREFIX.length(), GlobalConstants::PROTOCOL_PREFIX) == 0) diff --git a/src/downloader.cpp b/src/downloader.cpp index 18ef339..dc13aff 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -1851,7 +1851,7 @@ void Downloader::checkStatus() // GOG only provides xml data for installers, patches and language packs if (type & (GlobalConstants::GFTYPE_INSTALLER | GlobalConstants::GFTYPE_PATCH | GlobalConstants::GFTYPE_LANGPACK)) remoteHash = this->getRemoteFileHash(vGameFiles[i]); - std::string localHash = this->getLocalFileHash(filepath.string(), gamename); + std::string localHash = Util::getLocalFileHash(Globals::globalConfig.sXMLDirectory, filepath.string(), gamename, Globals::globalConfig.bUseFastCheck); if (!remoteHash.empty()) { diff --git a/src/util.cpp b/src/util.cpp index dc80f27..f62a83f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -663,7 +663,7 @@ void Util::parseOptionString(const std::string &option_string, std::vector