better startup time when using --game regex

... especially when using generic --ignore-dlc-count='.*'

previously, lgogdownloader would fetch game details for every game
that indicated that it has DLCs. Which were all of them when used with
--ignore-dlc-count - potentialy hundreds of http queries and cause of very slow
startup with larger accounts. Regardless of what --game regex said.

After the change, only initial list of all games is fetched, and then details
for games that both the user is interested in AND they are suspected of
having DLC. So it should help with startup time even when user doesn't use
--ignore-dlc-count option.
This commit is contained in:
Petr Běhan 2015-06-04 16:25:21 +02:00
parent 834e6baa7a
commit 3de1c8332e

View File

@ -2142,16 +2142,30 @@ std::vector<gameItem> Downloader::getGames()
{ {
int dlcCount = product["dlcCount"].asInt(); int dlcCount = product["dlcCount"].asInt();
bool bIgnoreDLCCount = false; bool bDownloadDLCInfo = (dlcCount != 0);
if (!config.sIgnoreDLCCountRegex.empty())
if (!bDownloadDLCInfo && !config.sIgnoreDLCCountRegex.empty())
{ {
boost::regex expression(config.sIgnoreDLCCountRegex); boost::regex expression(config.sIgnoreDLCCountRegex);
boost::match_results<std::string::const_iterator> what; boost::match_results<std::string::const_iterator> what;
if (boost::regex_search(game.name, what, expression)) // Check if name matches the specified regex if (boost::regex_search(game.name, what, expression)) // Check if name matches the specified regex
bIgnoreDLCCount = true; {
bDownloadDLCInfo = true;
}
} }
if (dlcCount != 0 || bIgnoreDLCCount) if (bDownloadDLCInfo && !config.sGameRegex.empty())
{
// don't download unnecessary info if user is only interested in a subset of his account
boost::regex expression(config.sGameRegex);
boost::match_results<std::string::const_iterator> what;
if (!boost::regex_search(game.name, what, expression))
{
bDownloadDLCInfo = false;
}
}
if (bDownloadDLCInfo)
{ {
std::string gameinfo = this->getResponse("https://www.gog.com/account/gameDetails/" + game.id + ".json"); std::string gameinfo = this->getResponse("https://www.gog.com/account/gameDetails/" + game.id + ".json");
Json::Value info; Json::Value info;