Re: [PATCH 07/11] Resumable clone: add resumable download to http/curl
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 16, 2016, 22:45 UTC
- Message-ID
- <xmqqfuozihuv.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1473984742-12516-8-git-send-email-kevin.m.wern@gmail.com>
Kevin Wern <kevin.m.wern@gmail.com> writes:
Show 19 quoted lines
> +int http_download_primer(const char *url, const char *out_file)
> +{
> + int ret = 0, try_count = HTTP_TRY_COUNT;
> + struct http_get_options options = {0};
> + options.progress = 1;
> +
> + if (file_exists(out_file)) {
> + fprintf(stderr,
> + "File already downloaded: '%s', skipping...\n",
> + out_file);
> + return ret;
> + }
> +
> + do {
> + if (try_count != HTTP_TRY_COUNT) {
> + fprintf(stderr, "Connection interrupted for some "
> + "reason, retrying (%d attempts left)\n",
> + try_count);
> + struct timeval time = {10, 0}; // 1sWe do not use // comment.
> + select(0, NULL, NULL, NULL, &time); > + } > + ret = http_get_file(url, out_file, &options);
I didn't realize that http_get_file() -> http_request() codepath, when it is the output file, already can do the "ftell and request the reminder". Very nice.
Show 11 quoted lines
> @@ -1136,7 +1138,10 @@ static int handle_curl_result(struct slot_results *results) > curl_easy_strerror(results->curl_result), > sizeof(curl_errorstr)); > #endif > - return HTTP_ERROR; > + if (results->http_code >= 400) > + return HTTP_ERROR; > + else > + return HTTP_ERROR_RESUMABLE; > } > }
Hmm, is "anything below 400" a good definition of resumable errors?