[pacman-dev] [PATCH 1/2] pacman: fix alignment when download eta > 1h

Allan McRae allan at archlinux.org
Thu Jan 28 03:09:16 UTC 2021


On 17/1/21 2:32 am, morganamilo wrote:
> When the download estimate is over an hour the format displayed changes
> from mm:ss to hh:mm:ss. This causes everything to be out of alignment
> die to the extra characters.
> 
> So intead, when the estimate is over an our change to the format 4h33m.
> 
> Do note that before pacman would display --:-- as the estimate if the
> download was >= 100 hours. Now this is displayed if the downlaod is =>
> 10 hours.
> ---

How about, we just display the time if it is less than 100 minutes?  On
any reasonable connection (even by Australian standards), the vast
majority of packages should download within that timeframe.  And times
are not particularly accurate beyond that.

>  src/pacman/callback.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/pacman/callback.c b/src/pacman/callback.c
> index 7468ed7e..279338e7 100644
> --- a/src/pacman/callback.c
> +++ b/src/pacman/callback.c
> @@ -865,8 +865,8 @@ static void draw_pacman_progress_bar(struct pacman_progress_bar *bar)
>  	}
>  	if(eta_h == 0) {
>  		printf("%02u:%02u", eta_m, eta_s);
> -	} else if(eta_h < 100) {
> -		printf("%02u:%02u:%02u", eta_h, eta_m, eta_s);
> +	} else if(eta_h < 10) {
> +		printf("%01uh%02um", eta_h, eta_m);
>  	} else {
>  		fputs("--:--", stdout);
>  	}
> 


More information about the pacman-dev mailing list