diff --git a/include/config.h b/include/config.h index 2dbcc21..52a02bc 100644 --- a/include/config.h +++ b/include/config.h @@ -190,6 +190,8 @@ struct CurlConfig std::string sUserAgent; long int iTimeout; curl_off_t iDownloadRate; + long int iLowSpeedTimeout; + long int iLowSpeedTimeoutRate; }; struct GogAPIConfig diff --git a/main.cpp b/main.cpp index 8adcc17..1c95842 100644 --- a/main.cpp +++ b/main.cpp @@ -219,6 +219,8 @@ int main(int argc, char *argv[]) ("threads", bpo::value(&Globals::globalConfig.iThreads)->default_value(4), "Number of download threads") ("dlc-list", bpo::value(&Globals::globalConfig.sGameHasDLCList)->default_value("https://raw.githubusercontent.com/Sude-/lgogdownloader-lists/master/game_has_dlc.txt"), "Set URL for list of games that have DLC") ("progress-interval", bpo::value(&Globals::globalConfig.iProgressInterval)->default_value(100), "Set interval for progress bar update (milliseconds)\nValue must be between 1 and 10000") + ("lowspeed-timeout", bpo::value(&Globals::globalConfig.curlConf.iLowSpeedTimeout)->default_value(30), "Set time in number seconds that the transfer speed should be below the rate set with --lowspeed-rate for it to considered too slow and aborted") + ("lowspeed-rate", bpo::value(&Globals::globalConfig.curlConf.iLowSpeedTimeoutRate)->default_value(200), "Set average transfer speed in bytes per second that the transfer should be below during time specified with --lowspeed-timeout for it to be considered too slow and aborted") ; // Options read from config file options_cfg_only.add_options() diff --git a/src/downloader.cpp b/src/downloader.cpp index 2e8a2b2..fb04402 100644 --- a/src/downloader.cpp +++ b/src/downloader.cpp @@ -96,8 +96,8 @@ Downloader::Downloader() curl_easy_setopt(curlhandle, CURLOPT_XFERINFODATA, this); // Assume that we have connection error and abort transfer with CURLE_OPERATION_TIMEDOUT if download speed is less than 200 B/s for 30 seconds - curl_easy_setopt(curlhandle, CURLOPT_LOW_SPEED_TIME, 30); - curl_easy_setopt(curlhandle, CURLOPT_LOW_SPEED_LIMIT, 200); + curl_easy_setopt(curlhandle, CURLOPT_LOW_SPEED_TIME, Globals::globalConfig.curlConf.iLowSpeedTimeout); + curl_easy_setopt(curlhandle, CURLOPT_LOW_SPEED_LIMIT, Globals::globalConfig.curlConf.iLowSpeedTimeoutRate); if (!Globals::globalConfig.curlConf.sCACertPath.empty()) curl_easy_setopt(curlhandle, CURLOPT_CAINFO, Globals::globalConfig.curlConf.sCACertPath.c_str()); @@ -2656,8 +2656,8 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid) curl_easy_setopt(dlhandle, CURLOPT_FILETIME, 1L); // Assume that we have connection error and abort transfer with CURLE_OPERATION_TIMEDOUT if download speed is less than 200 B/s for 30 seconds - curl_easy_setopt(dlhandle, CURLOPT_LOW_SPEED_TIME, 30); - curl_easy_setopt(dlhandle, CURLOPT_LOW_SPEED_LIMIT, 200); + curl_easy_setopt(dlhandle, CURLOPT_LOW_SPEED_TIME, conf.curlConf.iLowSpeedTimeout); + curl_easy_setopt(dlhandle, CURLOPT_LOW_SPEED_LIMIT, conf.curlConf.iLowSpeedTimeoutRate); if (!conf.curlConf.sCACertPath.empty()) curl_easy_setopt(dlhandle, CURLOPT_CAINFO, conf.curlConf.sCACertPath.c_str()); diff --git a/src/galaxyapi.cpp b/src/galaxyapi.cpp index b36b01c..4462e73 100644 --- a/src/galaxyapi.cpp +++ b/src/galaxyapi.cpp @@ -39,8 +39,8 @@ galaxyAPI::galaxyAPI(CurlConfig& conf) curl_easy_setopt(curlhandle, CURLOPT_MAX_RECV_SPEED_LARGE, curlConf.iDownloadRate); // Assume that we have connection error and abort transfer with CURLE_OPERATION_TIMEDOUT if download speed is less than 200 B/s for 30 seconds - curl_easy_setopt(curlhandle, CURLOPT_LOW_SPEED_TIME, 30); - curl_easy_setopt(curlhandle, CURLOPT_LOW_SPEED_LIMIT, 200); + curl_easy_setopt(curlhandle, CURLOPT_LOW_SPEED_TIME, curlConf.iLowSpeedTimeout); + curl_easy_setopt(curlhandle, CURLOPT_LOW_SPEED_LIMIT, curlConf.iLowSpeedTimeoutRate); if (!curlConf.sCACertPath.empty()) curl_easy_setopt(curlhandle, CURLOPT_CAINFO, curlConf.sCACertPath.c_str());