diff mbox series

[19/29] channel_curl: do not check download size if range requested

Message ID 20211011112156.44192-20-sbabic@denx.de
State Changes Requested
Headers show
Series DELTA Update | expand

Commit Message

Stefano Babic Oct. 11, 2021, 11:21 a.m. UTC
In case just a part of file via bytes-range is requested, do not ask the
server for the size of the file to be downloaded.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 corelib/channel_curl.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c
index bed631b..4aebaa5 100644
--- a/corelib/channel_curl.c
+++ b/corelib/channel_curl.c
@@ -1147,14 +1147,20 @@  channel_op_res_t channel_get_file(channel_t *this, void *data)
 	}
 
 	download_callback_data_t download_data;
-	if (channel_enable_download_progress_tracking(channel_curl,
-				channel_data->url,
-				&download_data) == CHANNEL_EINIT) {
-		WARN("Failed to get total download size for URL %s.",
+	/*
+	 * In case of range do not ask the server for file size
+	 */
+	if (!channel_data->range)  {
+		if (channel_enable_download_progress_tracking(channel_curl,
+								channel_data->url,
+								&download_data) == CHANNEL_EINIT) {
+			WARN("Failed to get total download size for URL %s.",
 				channel_data->url);
 	} else
 		INFO("Total download size is %lu kB.",
-				download_data.total_download_size / 1024);
+			download_data.total_download_size / 1024);
+
+	}
 
 	if (curl_easy_setopt(channel_curl->handle, CURLOPT_CUSTOMREQUEST, "GET") !=
 	    CURLE_OK) {