diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2023-11-11 22:28:44 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2023-11-11 22:43:33 +0300 |
commit | 175ec788d14db88a2fafb920c8b5117209c12d5b (patch) | |
tree | 5ff4a7d314ce3887c5df8f051d83866edd585ac1 /contrib/libs/curl/lib/file.c | |
parent | b6c20a8a26d0be34045f2604b4da1ee189920ed2 (diff) | |
download | ydb-175ec788d14db88a2fafb920c8b5117209c12d5b.tar.gz |
Update contrib/libs/curl to 8.2.1
Diffstat (limited to 'contrib/libs/curl/lib/file.c')
-rw-r--r-- | contrib/libs/curl/lib/file.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/contrib/libs/curl/lib/file.c b/contrib/libs/curl/lib/file.c index d82d57b463..c751e8861a 100644 --- a/contrib/libs/curl/lib/file.c +++ b/contrib/libs/curl/lib/file.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -150,9 +150,19 @@ static CURLcode file_connect(struct Curl_easy *data, bool *done) char *actual_path; #endif size_t real_path_len; + CURLcode result; + + if(file->path) { + /* already connected. + * the handler->connect_it() is normally only called once, but + * FILE does a special check on setting up the connection which + * calls this explicitly. */ + *done = TRUE; + return CURLE_OK; + } - CURLcode result = Curl_urldecode(data->state.up.path, 0, &real_path, - &real_path_len, REJECT_ZERO); + result = Curl_urldecode(data->state.up.path, 0, &real_path, + &real_path_len, REJECT_ZERO); if(result) return result; @@ -226,10 +236,11 @@ static CURLcode file_connect(struct Curl_easy *data, bool *done) file->path = real_path; #endif #endif + Curl_safefree(file->freepath); file->freepath = real_path; /* free this when done */ file->fd = fd; - if(!data->set.upload && (fd == -1)) { + if(!data->state.upload && (fd == -1)) { failf(data, "Couldn't open file %s", data->state.up.path); file_done(data, CURLE_FILE_COULDNT_READ_FILE, FALSE); return CURLE_FILE_COULDNT_READ_FILE; @@ -329,7 +340,7 @@ static CURLcode file_upload(struct Curl_easy *data) while(!result) { size_t nread; - size_t nwrite; + ssize_t nwrite; size_t readcount; result = Curl_fillreadbuffer(data, data->set.buffer_size, &readcount); if(result) @@ -340,7 +351,7 @@ static CURLcode file_upload(struct Curl_easy *data) nread = readcount; - /*skip bytes before resume point*/ + /* skip bytes before resume point */ if(data->state.resume_from) { if((curl_off_t)nread <= data->state.resume_from) { data->state.resume_from -= nread; @@ -358,7 +369,7 @@ static CURLcode file_upload(struct Curl_easy *data) /* write the data to the target */ nwrite = write(fd, buf2, nread); - if(nwrite != nread) { + if((size_t)nwrite != nread) { result = CURLE_SEND_ERROR; break; } @@ -411,7 +422,7 @@ static CURLcode file_do(struct Curl_easy *data, bool *done) Curl_pgrsStartNow(data); - if(data->set.upload) + if(data->state.upload) return file_upload(data); file = data->req.p.file; @@ -471,13 +482,13 @@ static CURLcode file_do(struct Curl_easy *data, bool *done) tm->tm_hour, tm->tm_min, tm->tm_sec, - data->set.opt_no_body ? "": "\r\n"); + data->req.no_body ? "": "\r\n"); result = Curl_client_write(data, CLIENTWRITE_HEADER, header, headerlen); if(result) return result; /* set the file size to make it available post transfer */ Curl_pgrsSetDownloadSize(data, expected_size); - if(data->set.opt_no_body) + if(data->req.no_body) return result; } |