[pve-devel] [PATCH widget-toolkit] StatusView: fix usage calculation for fields without valid values

Dominik Csapak d.csapak at proxmox.com
Thu Mar 10 15:31:37 CET 2022


Sometimes, total can be zero (e.g. for swap when it's not used), which
leads to the usage being NaN. This led to the progressbar not being
updated for InfoWidgets, leaving a spurious '0%' as text.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/panel/StatusView.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/panel/StatusView.js b/src/panel/StatusView.js
index 4a60dae..e2e81e2 100644
--- a/src/panel/StatusView.js
+++ b/src/panel/StatusView.js
@@ -47,7 +47,7 @@ Ext.define('Proxmox.panel.StatusView', {
 	     */
 	    if (used.used !== undefined &&
 		used.total !== undefined) {
-		return used.used/used.total;
+		return used.total > 0 ? used.used/used.total : 0;
 	    }
 	}
 
-- 
2.30.2






More information about the pve-devel mailing list