Skip to content

Commit

Permalink
Add slow-speed timeout when downloading mod (#611)
Browse files Browse the repository at this point in the history
Abort request if network connection is dropped or too slow.
  • Loading branch information
Alystrasz authored Jan 20, 2024
1 parent c7edf9b commit bf7b5e0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions primedev/mods/autodownload/moddownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ std::optional<fs::path> ModDownloader::FetchModFromDistantStore(std::string_view

curl_easy_setopt(easyhandle, CURLOPT_URL, url.data());
curl_easy_setopt(easyhandle, CURLOPT_FAILONERROR, 1L);

// abort if slower than 30 bytes/sec during 10 seconds
curl_easy_setopt(easyhandle, CURLOPT_LOW_SPEED_TIME, 10L);
curl_easy_setopt(easyhandle, CURLOPT_LOW_SPEED_LIMIT, 30L);

curl_easy_setopt(easyhandle, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, WriteData);
curl_easy_setopt(easyhandle, CURLOPT_NOPROGRESS, 0L);
Expand Down

0 comments on commit bf7b5e0

Please sign in to comment.