mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
Changed --check-orphans to set regular expression filter for orphan check.
If no argument is given then the regex defaults to '.*\.(zip|exe|bin|dmg|old)$'
This commit is contained in:
parent
b49c12b88c
commit
b59210c251
@ -31,7 +31,6 @@ class Config
|
|||||||
bool bUnicode; // use Unicode in console output
|
bool bUnicode; // use Unicode in console output
|
||||||
bool bColor; // use colors
|
bool bColor; // use colors
|
||||||
bool bVerifyPeer;
|
bool bVerifyPeer;
|
||||||
bool bCheckOrphans;
|
|
||||||
bool bCheckStatus;
|
bool bCheckStatus;
|
||||||
bool bDuplicateHandler;
|
bool bDuplicateHandler;
|
||||||
std::string sGameRegex;
|
std::string sGameRegex;
|
||||||
@ -44,6 +43,7 @@ class Config
|
|||||||
std::string sConfigDirectory;
|
std::string sConfigDirectory;
|
||||||
std::string sCookiePath;
|
std::string sCookiePath;
|
||||||
std::string sConfigFilePath;
|
std::string sConfigFilePath;
|
||||||
|
std::string sOrphanRegex;
|
||||||
unsigned int iInstallerType;
|
unsigned int iInstallerType;
|
||||||
unsigned int iInstallerLanguage;
|
unsigned int iInstallerLanguage;
|
||||||
size_t iChunkSize;
|
size_t iChunkSize;
|
||||||
|
12
main.cpp
12
main.cpp
@ -97,6 +97,10 @@ int main(int argc, char *argv[])
|
|||||||
language_text += "Add the values to download multiple languages\nAll = " + std::to_string(language_sum) + "\n"
|
language_text += "Add the values to download multiple languages\nAll = " + std::to_string(language_sum) + "\n"
|
||||||
+ "French + Polish = " + std::to_string(GlobalConstants::LANGUAGE_FR) + "+" + std::to_string(GlobalConstants::LANGUAGE_PL) + " = " + std::to_string(GlobalConstants::LANGUAGE_FR | GlobalConstants::LANGUAGE_PL);
|
+ "French + Polish = " + std::to_string(GlobalConstants::LANGUAGE_FR) + "+" + std::to_string(GlobalConstants::LANGUAGE_PL) + " = " + std::to_string(GlobalConstants::LANGUAGE_FR | GlobalConstants::LANGUAGE_PL);
|
||||||
|
|
||||||
|
// Create help text for --check-orphans
|
||||||
|
std::string orphans_regex_default = ".*\\.(zip|exe|bin|dmg|old)$"; // Limit to files with these extensions (".old" is for renamed older version files)
|
||||||
|
std::string check_orphans_text = "Check for orphaned files (files found on local filesystem that are not found on GOG servers). Sets regular expression filter (Perl syntax) for files to check. If no argument is given then the regex defaults to '" + orphans_regex_default + "'";
|
||||||
|
|
||||||
bpo::variables_map vm;
|
bpo::variables_map vm;
|
||||||
bpo::options_description desc("Options");
|
bpo::options_description desc("Options");
|
||||||
bpo::options_description config_file_options("Configuration");
|
bpo::options_description config_file_options("Configuration");
|
||||||
@ -140,7 +144,7 @@ int main(int argc, char *argv[])
|
|||||||
("verbose", bpo::value<bool>(&config.bVerbose)->zero_tokens()->default_value(false), "Print lots of information")
|
("verbose", bpo::value<bool>(&config.bVerbose)->zero_tokens()->default_value(false), "Print lots of information")
|
||||||
("insecure", bpo::value<bool>(&bInsecure)->zero_tokens()->default_value(false), "Don't verify authenticity of SSL certificates")
|
("insecure", bpo::value<bool>(&bInsecure)->zero_tokens()->default_value(false), "Don't verify authenticity of SSL certificates")
|
||||||
("timeout", bpo::value<long int>(&config.iTimeout)->default_value(10), "Set timeout for connection\nMaximum time in seconds that connection phase is allowed to take")
|
("timeout", bpo::value<long int>(&config.iTimeout)->default_value(10), "Set timeout for connection\nMaximum time in seconds that connection phase is allowed to take")
|
||||||
("check-orphans", bpo::value<bool>(&config.bCheckOrphans)->zero_tokens()->default_value(false), "Check for orphaned files (files found on local filesystem that are not found on GOG servers)")
|
("check-orphans", bpo::value<std::string>(&config.sOrphanRegex)->implicit_value(""), check_orphans_text.c_str())
|
||||||
("status", bpo::value<bool>(&config.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")
|
("status", bpo::value<bool>(&config.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")
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -182,6 +186,10 @@ int main(int argc, char *argv[])
|
|||||||
if (vm.count("limit-rate"))
|
if (vm.count("limit-rate"))
|
||||||
config.iDownloadRate <<= 10; // Convert download rate from bytes to kilobytes
|
config.iDownloadRate <<= 10; // Convert download rate from bytes to kilobytes
|
||||||
|
|
||||||
|
if (vm.count("check-orphans"))
|
||||||
|
if (config.sOrphanRegex.empty())
|
||||||
|
config.sOrphanRegex = orphans_regex_default;
|
||||||
|
|
||||||
config.bVerifyPeer = !bInsecure;
|
config.bVerifyPeer = !bInsecure;
|
||||||
config.bColor = !bNoColor;
|
config.bColor = !bNoColor;
|
||||||
config.bUnicode = !bNoUnicode;
|
config.bUnicode = !bNoUnicode;
|
||||||
@ -248,7 +256,7 @@ int main(int argc, char *argv[])
|
|||||||
downloader.download();
|
downloader.download();
|
||||||
else if (config.bListDetails || config.bList) // Detailed list of games/extras
|
else if (config.bListDetails || config.bList) // Detailed list of games/extras
|
||||||
downloader.listGames();
|
downloader.listGames();
|
||||||
else if (config.bCheckOrphans)
|
else if (!config.sOrphanRegex.empty()) // Check for orphaned files if regex for orphans is set
|
||||||
downloader.checkOrphans();
|
downloader.checkOrphans();
|
||||||
else if (config.bCheckStatus)
|
else if (config.bCheckStatus)
|
||||||
downloader.checkStatus();
|
downloader.checkStatus();
|
||||||
|
@ -1481,7 +1481,7 @@ void Downloader::checkOrphans()
|
|||||||
if (boost::filesystem::is_regular_file(dir_iter->status()))
|
if (boost::filesystem::is_regular_file(dir_iter->status()))
|
||||||
{
|
{
|
||||||
std::string filename = dir_iter->path().filename().string();
|
std::string filename = dir_iter->path().filename().string();
|
||||||
boost::regex expression(".*\\.(zip|exe|bin|dmg|old)$"); // Limit to files with these extensions (".old" is for renamed older version files)
|
boost::regex expression(config.sOrphanRegex); // Limit to files matching the regex
|
||||||
boost::match_results<std::string::const_iterator> what;
|
boost::match_results<std::string::const_iterator> what;
|
||||||
if (boost::regex_search(filename, what, expression))
|
if (boost::regex_search(filename, what, expression))
|
||||||
filepath_vector.push_back(dir_iter->path());
|
filepath_vector.push_back(dir_iter->path());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user