curl/backport-ftp-support-growing-files-with-CURLOPT_IGNORE_CONTEN.patch
sherlock2010 fd9fed8b41 backport some patches from community
(cherry picked from commit 8afd3b243da43e6602d4780fa0312fc72c31449d)
2024-01-04 19:08:04 +08:00

40 lines
1.5 KiB
Diff

From 76b3f5f2cf0f091720413690c49f8d0ada5bfae5 Mon Sep 17 00:00:00 2001
From: fractal-access <116177727+fractal-access@users.noreply.github.com>
Date: Wed, 19 Oct 2022 14:37:44 +0100
Subject: [PATCH] ftp: support growing files with CURLOPT_IGNORE_CONTENT_LENGTH
When using the option CURLOPT_IGNORE_CONTENT_LENGTH (set.ignorecl in
code) to support growing files in FTP, the code should ignore the
initial size it gets from the server as this will not be the final size
of the file. This is done in ftp_state_quote() to prevent a size request
being issued in the initial sequence. However, in a later call to
ftp_state_get_resp() the code attempts to get the size of the content
again if it doesn't already have it, by parsing the response from the
RETR request. This fix prevents this parsing of the response to get the
size when the set.ignorecl option is set. This should maintain the size
value as -1, unknown, in this situation.
Closes #9772
Conflict: NA
Reference: https://github.com/curl/curl/commit/76b3f5f2cf0f091720413690c49f8d0ada5bfae5
---
lib/ftp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/ftp.c b/lib/ftp.c
index c6e31e1b6..c07bafe17 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -2448,6 +2448,7 @@ static CURLcode ftp_state_get_resp(struct Curl_easy *data,
if((instate != FTP_LIST) &&
!data->state.prefer_ascii &&
+ !data->set.ignorecl &&
(ftp->downloadsize < 1)) {
/*
* It seems directory listings either don't show the size or very
--
2.33.0