From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 5B6C91FF13A for ; Wed, 27 May 2026 17:32:35 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 209AE314; Wed, 27 May 2026 17:32:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779892952; x=1780497752; darn=lists.proxmox.com; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Az/XLFR0yo7HYJECaqJwfi6j8l5CP6OiwjVMioLEZnA=; b=G5keJioXyUer4KyAVKROu97n/AZkKwlJ4b8t/pPVfihyqbN++W6uc/LCsR9YXZSX1S bBCzoM/jC7ikv3eJ5FiWhodsU8tX7OI4pyT5KztpeVd8oGOXQcsgspKUof5dGvKQvvmZ BYOyWAZtyOt6Jb5kN7AADEiQ7NrZsz/2Uw3VuglzzOB+H6Cbm8rd2Ud+M5ebq5EUMT8r LS6BqKLACo/sbTBJiIW8Wb2MAF0foL5EN8liw2GIl7OSORtGJyUDSzfVjTH7l6FF8ARs jvEhKYOq+g4nCnQtgpr/1aG3E/ntpDaN1kLWD7O9j9f4mhvFJ5waLsaXRnoO6OHSaIhc byWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779892952; x=1780497752; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Az/XLFR0yo7HYJECaqJwfi6j8l5CP6OiwjVMioLEZnA=; b=a7Yphp0YrN/bp94hIoCloqBA7ruHeqMkDtqes7GRUp7jXYSO2gLQqEPKXEEh+T72oL hCdaCU1KKCNqe9I3dLuxJrKhQexr1GLaDFA52M0HN+wC5hkSm8xZZjIqBaHainiujXO1 s99xiIQ/+GbFYggHF2BROQx7GCzgLtuVqJL6nXtYPAbIvALT1SAkORLj1mavTU8LFc0w NRDJsnL7Btzfh9TQtOVsAIXlE9XH8suxhl2qWdYvyI+C6idcRxD8pdMe6MSosOEV1vGd isCrYYcR8DpOgebZAmm8zNI5vUj7LdJZh3e6IklAP8kY9q2hYwgvIi/F9hbUzArCJYIK uzVg== X-Gm-Message-State: AOJu0YxMQMd6TJhu9hUOaW9h0yqY6D0Hy0XsaQR4ZvjtZrUuu0YXkMbh dpFlJ9EntYfc6ySwUuWy1YkjAScmQKoM6je6EwwD6acUTQVUT0lN7UFk3ZlqzaKU X-Gm-Gg: Acq92OFdDirjwr0u7pidc9dNXIb/JsWB5JFQxv2R+VYLUbIVPq7IfzaOROX4y2vXSJ5 Nz8SJe/uF6WuiXBYWDmrEQewU7yPJ4PQWO8DDIHn8Z5ebdRXMV6ofWNXVcqBA+jMs3GtZ0at6OD HJNMzXFhYlaN4V2coGOsI6HyBuiJw3vOlkShhQuspU0BOuAg+cKuwhbsmDjbGcGTKsIAw1z4KOG 9o/w+6IA7nRofxup796rEWxwKOPwmE+HlFbqOD3dgMG3faAZqSKDSibaosg/dTmTvjQzJuAQjWw irMTwyFzUob5QyA6g7ofnjozW0BFLH8YRzha3jXYTKZ8T3hapd/Fm0+B/o36dBsaObCjyuBja7x xCv6E53RwcEYLUk/csHzZdbuSfg3TGFC2n0A0WwSClQexNvLWQjTG8bE3KO6FsUikuitPZjhTIN rS3CVg2eS6xpzNQHyIt6RNICnnUeQV6bVJKphU0X5/d+8mp/hLzkm63Px/m3OvNx8= X-Received: by 2002:a05:600c:1381:b0:490:51e2:bc86 with SMTP id 5b1f17b1804b1-49051e2be87mr304150325e9.23.1779892952128; Wed, 27 May 2026 07:42:32 -0700 (PDT) From: David Gonzalo Rodriguez To: pve-devel@lists.proxmox.com Subject: [PATCH] Signed-off-by: David Gonzalo Rodriguez Date: Wed, 27 May 2026 16:41:43 +0200 Message-ID: <20260527144143.860766-1-z80user@gmail.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record X-MailFrom: z80user@gmail.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation Message-ID-Hash: SV2H5IR36KEJVGGEQKWU7X3B6C3CKBQ2 X-Message-ID-Hash: SV2H5IR36KEJVGGEQKWU7X3B6C3CKBQ2 X-Mailman-Approved-At: Wed, 27 May 2026 17:32:16 +0200 CC: David Gonzalo Rodriguez X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Fix the unit to show GiB on the user interface as default, it will show "useSI" on the right units if is setup on the variable as true or false The use a ternary expression here would produce incorrect results. usually "useSI" is an object instead true or false. --- pve-common | 1 + src/Utils.js | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 160000 pve-common diff --git a/pve-common b/pve-common new file mode 160000 index 0000000..971bb05 --- /dev/null +++ b/pve-common @@ -0,0 +1 @@ +Subproject commit 971bb05bf9ef4897083d8366e459a92b2b36c763 diff --git a/src/Utils.js b/src/Utils.js index 7643316..71e027a 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -808,17 +808,35 @@ Ext.define('Proxmox.Utils', { ]; let order = 0; let commaDigits = 2; - const baseValue = useSI ? 1000 : 1024; + +// Do not use a ternary expression here and on the next check. +// `useSI` may not exist and implicit truthy/falsy conversion +// would produce incorrect results. + let baseValue = 1024; + if (useSI === true) { + baseValue = 1000; + } + if (useSI === false) { + baseValue = 1024; + } while (size >= baseValue && order < unitsSI.length) { size = size / baseValue; order++; } - let unit = useSI ? unitsSI[order] : unitsIEC[order]; + unit = unitsIEC[order]; + if (useSI === true) { + unit = unitsSI[order]; + } + if (useSI === false) { + unit = unitsIEC[order]; + } if (order === 0) { commaDigits = 0; } return `${size.toFixed(commaDigits)} ${unit}`; + + }, SizeUnits: { -- 2.47.3