summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/file.c
diff options
context:
space:
mode:
authordartraiden <wowemuh@gmail.com>2021-04-17 17:28:44 +0300
committerdartraiden <wowemuh@gmail.com>2021-04-17 17:28:44 +0300
commit5612cd9c7b03972631c46d117c595a34e71ecafd (patch)
tree791e0aafd46c353e6edfbba8369577fad21bdfe0 /libs/libcurl/src/file.c
parent6f2d6282c4efac04c18dcc7d493e18a3aaf08ad3 (diff)
libcurl: update to 7.76.1
Diffstat (limited to 'libs/libcurl/src/file.c')
-rw-r--r--libs/libcurl/src/file.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/libs/libcurl/src/file.c b/libs/libcurl/src/file.c
index dd8a1fd12a..1d174e519e 100644
--- a/libs/libcurl/src/file.c
+++ b/libs/libcurl/src/file.c
@@ -417,12 +417,12 @@ static CURLcode file_do(struct Curl_easy *data, bool *done)
result = Curl_client_write(data, CLIENTWRITE_HEADER, header, 0);
if(result)
return result;
- }
- result = Curl_client_write(data, CLIENTWRITE_HEADER,
- (char *)"Accept-ranges: bytes\r\n", 0);
- if(result)
- return result;
+ result = Curl_client_write(data, CLIENTWRITE_HEADER,
+ (char *)"Accept-ranges: bytes\r\n", 0);
+ if(result != CURLE_OK)
+ return result;
+ }
filetime = (time_t)statbuf.st_mtime;
result = Curl_gmtime(filetime, &buffer);
@@ -464,18 +464,23 @@ static CURLcode file_do(struct Curl_easy *data, bool *done)
data->state.resume_from += (curl_off_t)statbuf.st_size;
}
- if(data->state.resume_from <= expected_size)
- expected_size -= data->state.resume_from;
- else {
- failf(data, "failed to resume file:// transfer");
- return CURLE_BAD_DOWNLOAD_RESUME;
+ if(data->state.resume_from > 0) {
+ /* We check explicitly if we have a start offset, because
+ * expected_size may be -1 if we don't know how large the file is,
+ * in which case we should not adjust it. */
+ if(data->state.resume_from <= expected_size)
+ expected_size -= data->state.resume_from;
+ else {
+ failf(data, "failed to resume file:// transfer");
+ return CURLE_BAD_DOWNLOAD_RESUME;
+ }
}
/* A high water mark has been specified so we obey... */
if(data->req.maxdownload > 0)
expected_size = data->req.maxdownload;
- if(!fstated || (expected_size == 0))
+ if(!fstated || (expected_size <= 0))
size_known = FALSE;
else
size_known = TRUE;
@@ -484,7 +489,7 @@ static CURLcode file_do(struct Curl_easy *data, bool *done)
this is both more efficient than the former call to download() and
it avoids problems with select() and recv() on file descriptors
in Winsock */
- if(fstated)
+ if(size_known)
Curl_pgrsSetDownloadSize(data, expected_size);
if(data->state.resume_from) {