mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 11:49:17 +01:00
Don't use depracated libcurl options
Use CURLINFO_SPEED_DOWNLOAD_T instead of CURLINFO_SPEED_DOWNLOAD Use CURLOPT_UPLOAD instead of CURLOPT_PUT
This commit is contained in:
parent
6ce6aeb1dc
commit
78c8f43576
@ -1609,9 +1609,12 @@ int Downloader::progressCallback(void *clientp, curl_off_t dltotal, curl_off_t d
|
|||||||
Downloader* downloader = static_cast<Downloader*>(clientp);
|
Downloader* downloader = static_cast<Downloader*>(clientp);
|
||||||
|
|
||||||
double rate; // average download speed in B/s
|
double rate; // average download speed in B/s
|
||||||
|
curl_off_t curl_rate;
|
||||||
// trying to get rate and setting to NaN if it fails
|
// trying to get rate and setting to NaN if it fails
|
||||||
if (CURLE_OK != curl_easy_getinfo(downloader->curlhandle, CURLINFO_SPEED_DOWNLOAD, &rate))
|
if (CURLE_OK != curl_easy_getinfo(downloader->curlhandle, CURLINFO_SPEED_DOWNLOAD_T, &curl_rate))
|
||||||
rate = std::numeric_limits<double>::quiet_NaN();
|
rate = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
else
|
||||||
|
rate = static_cast<double>(curl_rate);
|
||||||
|
|
||||||
// (Shmerl): this flag is needed to catch the case before anything was downloaded on resume,
|
// (Shmerl): this flag is needed to catch the case before anything was downloaded on resume,
|
||||||
// and there is no way to calculate the fraction, so we set to 0 (otherwise it'd be 1).
|
// and there is no way to calculate the fraction, so we set to 0 (otherwise it'd be 1).
|
||||||
@ -2673,7 +2676,7 @@ void Downloader::processCloudSaveUploadQueue(Config conf, const unsigned int& ti
|
|||||||
header = curl_slist_append(header, "Content-Type: Octet-Stream");
|
header = curl_slist_append(header, "Content-Type: Octet-Stream");
|
||||||
header = curl_slist_append(header, ("Content-Length: " + std::to_string(filecontents.size())).c_str());
|
header = curl_slist_append(header, ("Content-Length: " + std::to_string(filecontents.size())).c_str());
|
||||||
|
|
||||||
curl_easy_setopt(dlhandle, CURLOPT_PUT, 1L);
|
curl_easy_setopt(dlhandle, CURLOPT_UPLOAD, 1L);
|
||||||
curl_easy_setopt(dlhandle, CURLOPT_CUSTOMREQUEST, "PUT");
|
curl_easy_setopt(dlhandle, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||||
curl_easy_setopt(dlhandle, CURLOPT_HTTPHEADER, header);
|
curl_easy_setopt(dlhandle, CURLOPT_HTTPHEADER, header);
|
||||||
curl_easy_setopt(dlhandle, CURLOPT_READDATA, &cms);
|
curl_easy_setopt(dlhandle, CURLOPT_READDATA, &cms);
|
||||||
@ -3408,10 +3411,13 @@ int Downloader::progressCallbackForThread(void *clientp, curl_off_t dltotal, cur
|
|||||||
progressInfo info;
|
progressInfo info;
|
||||||
info.dlnow = dlnow;
|
info.dlnow = dlnow;
|
||||||
info.dltotal = dltotal;
|
info.dltotal = dltotal;
|
||||||
|
curl_off_t curl_rate;
|
||||||
|
|
||||||
// trying to get rate and setting to NaN if it fails
|
// trying to get rate and setting to NaN if it fails
|
||||||
if (CURLE_OK != curl_easy_getinfo(xferinfo->curlhandle, CURLINFO_SPEED_DOWNLOAD, &info.rate_avg))
|
if (CURLE_OK != curl_easy_getinfo(xferinfo->curlhandle, CURLINFO_SPEED_DOWNLOAD_T, &curl_rate))
|
||||||
info.rate_avg = std::numeric_limits<double>::quiet_NaN();
|
info.rate_avg = std::numeric_limits<double>::quiet_NaN();
|
||||||
|
else
|
||||||
|
info.rate_avg = static_cast<double>(curl_rate);
|
||||||
|
|
||||||
// setting full dlwnow and dltotal
|
// setting full dlwnow and dltotal
|
||||||
if (xferinfo->offset > 0)
|
if (xferinfo->offset > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user