diff mbox series

[3/3] downloader: allow common channel settings

Message ID 20240520063757.2456044-4-dominique.martinet@atmark-techno.com
State Changes Requested
Headers show
Series downloader curl options: add max-download-speed | expand

Commit Message

Dominique Martinet May 20, 2024, 6:37 a.m. UTC
The previous patch added max-download-speed so just add this one to
the config example, but using channel_settings() gets a few others
for free if someone ever requires setting them.

Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
---
 corelib/downloader.c                | 5 +----
 examples/configuration/swupdate.cfg | 4 ++++
 2 files changed, 5 insertions(+), 4 deletions(-)

Comments

Stefano Babic May 25, 2024, 3:31 p.m. UTC | #1
On 20.05.24 08:37, Dominique Martinet wrote:
> The previous patch added max-download-speed so just add this one to
> the config example, but using channel_settings() gets a few others
> for free if someone ever requires setting them.
>
> Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
> ---
>   corelib/downloader.c                | 5 +----
>   examples/configuration/swupdate.cfg | 4 ++++
>   2 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/corelib/downloader.c b/corelib/downloader.c
> index 04dea8b935ad..aae0066784b4 100644
> --- a/corelib/downloader.c
> +++ b/corelib/downloader.c
> @@ -107,12 +107,9 @@ static int download_settings(void *elem, void  __attribute__ ((__unused__)) *dat
>   		opt->auth = NULL;
>   	}
>
> -	get_field(LIBCFG_PARSER, elem, "retries",
> -		&opt->retries);
> -	get_field(LIBCFG_PARSER, elem, "retrywait",
> -		&opt->retry_sleep);
>   	get_field(LIBCFG_PARSER, elem, "timeout",
>   		&opt->low_speed_timeout);
> +	channel_settings(elem, &channel_options);
>
>   	return 0;
>   }
> diff --git a/examples/configuration/swupdate.cfg b/examples/configuration/swupdate.cfg
> index b46c92d924ca..24aae3285f90 100644
> --- a/examples/configuration/swupdate.cfg
> +++ b/examples/configuration/swupdate.cfg
> @@ -104,11 +104,15 @@ logcolors : {
>   # authentication	: string
>   #			  credentials needed to get software if server
>   #			  enables Basic Auth to allow this downloading
> +# max-download-speed    : string
> +#			  Specify maximum download speed to use. Value can be expressed as
> +#			  B/s, kB/s, M/s, G/s. Example: 512k
>   download :
>   {
>   	authentication = "user:password";
>   	retries = 3;
>   	timeout = 1800;
> +	max-download-speed = "1M";
>   	retrywait	= 5;
>   	url = "http://example.com/software.swu";
>   	userid		= 1000;

Reviewed-by: Stefano Babic <stefano.babic@swupdate.org>
diff mbox series

Patch

diff --git a/corelib/downloader.c b/corelib/downloader.c
index 04dea8b935ad..aae0066784b4 100644
--- a/corelib/downloader.c
+++ b/corelib/downloader.c
@@ -107,12 +107,9 @@  static int download_settings(void *elem, void  __attribute__ ((__unused__)) *dat
 		opt->auth = NULL;
 	}
 
-	get_field(LIBCFG_PARSER, elem, "retries",
-		&opt->retries);
-	get_field(LIBCFG_PARSER, elem, "retrywait",
-		&opt->retry_sleep);
 	get_field(LIBCFG_PARSER, elem, "timeout",
 		&opt->low_speed_timeout);
+	channel_settings(elem, &channel_options);
 
 	return 0;
 }
diff --git a/examples/configuration/swupdate.cfg b/examples/configuration/swupdate.cfg
index b46c92d924ca..24aae3285f90 100644
--- a/examples/configuration/swupdate.cfg
+++ b/examples/configuration/swupdate.cfg
@@ -104,11 +104,15 @@  logcolors : {
 # authentication	: string
 #			  credentials needed to get software if server
 #			  enables Basic Auth to allow this downloading
+# max-download-speed    : string
+#			  Specify maximum download speed to use. Value can be expressed as
+#			  B/s, kB/s, M/s, G/s. Example: 512k
 download :
 {
 	authentication = "user:password";
 	retries = 3;
 	timeout = 1800;
+	max-download-speed = "1M";
 	retrywait	= 5;
 	url = "http://example.com/software.swu";
 	userid		= 1000;