diff mbox series

[V2,22/36] channel_curl: do not check download size if range requested

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

Commit Message

Stefano Babic Nov. 14, 2021, 5:27 p.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 39c415d..2b9f178 100644
--- a/corelib/channel_curl.c
+++ b/corelib/channel_curl.c
@@ -1143,14 +1143,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) {