Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nix
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f8a1cc2d4781
Choose a base ref
...
head repository: NixOS/nix
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7827af1b6769
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Mar 30, 2020

  1. Verified

    This commit was signed with the committer’s verified signature.
    MichaReiser Micha Reiser
    Copy the full SHA
    7827af1 View commit details
Showing with 7 additions and 9 deletions.
  1. +7 −9 src/libstore/download.cc
16 changes: 7 additions & 9 deletions src/libstore/download.cc
Original file line number Diff line number Diff line change
@@ -308,7 +308,7 @@ struct CurlDownloader : public Downloader
curl_easy_setopt(req, CURLOPT_NETRC_FILE, settings.netrcFile.get().c_str());
curl_easy_setopt(req, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);

if (writtenToSink)
if (writtenToSink && acceptRanges && encoding.empty())
curl_easy_setopt(req, CURLOPT_RESUME_FROM_LARGE, writtenToSink);

result.data = std::make_shared<std::string>();
@@ -414,16 +414,14 @@ struct CurlDownloader : public Downloader

/* If this is a transient error, then maybe retry the
download after a while. If we're writing to a
sink, we can only retry if the server supports
ranged requests. */
if (err == Transient
&& attempt < request.tries
&& (!this->request.dataCallback
|| writtenToSink == 0
|| (acceptRanges && encoding.empty())))
sink, we can only resume if the server supports
ranged requests, otherwise fallback to a plain
retry.
*/
if (err == Transient && attempt < request.tries)
{
int ms = request.baseRetryTimeMs * std::pow(2.0f, attempt - 1 + std::uniform_real_distribution<>(0.0, 0.5)(downloader.mt19937));
if (writtenToSink)
if (writtenToSink && acceptRanges && encoding.empty())
warn("%s; retrying from offset %d in %d ms", exc.what(), writtenToSink, ms);
else
warn("%s; retrying in %d ms", exc.what(), ms);