[pacman-dev] [PATCH] libalpm: download rates becoming negative

Andrew Gregory andrew.gregory.8 at gmail.com
Mon Apr 19 04:53:01 UTC 2021


On 04/18/21 at 11:31pm, morganamilo wrote:
> When a download fails on one mirror a new download is started on the
> next mirror. This new download will have the initial size of whatever
> has been downloaded so far, as well as the ammount downloaded reset to
> 0.
> 
> To account for this, when a download changes mirror, save how much has
> been downloaded so far and add that to dlcb calls.
> ---
>  lib/libalpm/dload.c | 14 ++++++++++++--
>  lib/libalpm/dload.h |  1 +
>  2 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
> index a4c42f8d..27a7748a 100644
> --- a/lib/libalpm/dload.c
> +++ b/lib/libalpm/dload.c
> @@ -207,8 +207,8 @@ static int dload_progress_cb(void *file, curl_off_t dltotal, curl_off_t dlnow,
>  
>  	/* do NOT include initial_size since it wasn't part of the package's
>  	 * download_size (nor included in the total download size callback) */
> -	cb_data.total = dltotal;
> -	cb_data.downloaded = dlnow;
> +	cb_data.total = dltotal + payload->resetprogress;
> +	cb_data.downloaded = dlnow + payload->resetprogress;
>  	payload->handle->dlcb(payload->remote_name, ALPM_DOWNLOAD_PROGRESS, &cb_data);
>  	payload->prevprogress = current_size;
>  
> @@ -440,6 +440,16 @@ static int curl_retry_next_server(CURLM *curlm, CURL *curl, struct dload_payload
>  		fseek(payload->localf, 0, SEEK_SET);
>  	}
>  
> +
> +	/* reset progress for next server */
> +	payload->resetprogress += payload->prevprogress - payload->initial_size;
> +	payload->unlink_on_fail = 0;

Without looking at the rest of the patch, how does this line not just
straight up break unlink_on_fail functionality for any download that
falls back to another server?


More information about the pacman-dev mailing list