Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f8a1cc2

Browse files
committedMar 30, 2020
downloader: when retry but can't resume, retry the whole file
1 parent e322a16 commit f8a1cc2

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed
 

Diff for: ‎src/libstore/download.cc

+3-7
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ struct CurlDownloader : public Downloader
308308
curl_easy_setopt(req, CURLOPT_NETRC_FILE, settings.netrcFile.get().c_str());
309309
curl_easy_setopt(req, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
310310

311-
if (writtenToSink)
311+
if (writtenToSink && acceptRanges && encoding.empty())
312312
curl_easy_setopt(req, CURLOPT_RESUME_FROM_LARGE, writtenToSink);
313313

314314
result.data = std::make_shared<std::string>();
@@ -416,14 +416,10 @@ struct CurlDownloader : public Downloader
416416
download after a while. If we're writing to a
417417
sink, we can only retry if the server supports
418418
ranged requests. */
419-
if (err == Transient
420-
&& attempt < request.tries
421-
&& (!this->request.dataCallback
422-
|| writtenToSink == 0
423-
|| (acceptRanges && encoding.empty())))
419+
if (err == Transient && attempt < request.tries)
424420
{
425421
int ms = request.baseRetryTimeMs * std::pow(2.0f, attempt - 1 + std::uniform_real_distribution<>(0.0, 0.5)(downloader.mt19937));
426-
if (writtenToSink)
422+
if (writtenToSink && acceptRanges && encoding.empty())
427423
warn("%s; retrying from offset %d in %d ms", exc.what(), writtenToSink, ms);
428424
else
429425
warn("%s; retrying in %d ms", exc.what(), ms);

0 commit comments

Comments
 (0)
Please sign in to comment.