[pve-devel] [PATCH widget-toolkit 2/2] utils: format_size: show negative size as NA

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Jun 1 16:22:46 CEST 2023


Am 19/04/2023 um 12:34 schrieb Aaron Lauterer:
> Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
> ---
> 
> AFAIK we do not have negative sizes anywhere, and if, it is an
> indication that something is wrong.

above belongs in the commit message, additionaly some background for why doing
this now (i.e., did you run into this or what made you make this change?)

> 
>  src/Utils.js | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/Utils.js b/src/Utils.js
> index ef72630..8cdbe86 100644
> --- a/src/Utils.js
> +++ b/src/Utils.js
> @@ -688,6 +688,9 @@ utilities: {
>      },
>  
>      format_size: function(size, useSI) {
> +	if (size < 0) {
> +	    return gettext("N/A");

catching this seems OK, but I'd rather just return the value then, as "N/A" (Not
Applicable) doesn't really makes sense here and just hides a potential underlying
problem.

> +	}
>  	let units = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
>  	let order = 0;
>  	const baseValue = useSI ? 1000 : 1024;






More information about the pve-devel mailing list