Report disk capacity in decimal GB so it matches Unraid and the drive label

The API mixes units per field — memory in bytes, disk size in KiB, fsSize and
fsUsed in kB — and one helper was guessing which from the magnitude of the
number, which also read any memory total under 100 GB as KB.
This commit is contained in:
Gmer4Lfe
2026-08-13 18:07:09 -04:00
parent 57e2b0d670
commit b358dfcf58
3 changed files with 48 additions and 23 deletions
+6 -3
View File
@@ -448,8 +448,11 @@ function vv_disk_entry(array $d, string $key, string $role = 'data'): ?array {
'name' => $name,
'device' => $d['device'] ?? $key,
'role' => $role,
'size_gb' => round($size_kb / 1048576, 1),
'used_gb' => round($used_kb / 1048576, 1),
// disks.ini is KiB. This path was arithmetically right and still disagreed with the API
// path by 2.4% and with Unraid's own Main page by 7.4% — it produced GiB under a "GB"
// name. Decimal GB, so both sources of the same disk now land on the same number.
'size_gb' => round($size_kb * 1024 / 1e9, 1),
'used_gb' => round($used_kb * 1024 / 1e9, 1),
'pct' => (!$isParity && $size_kb > 0) ? round($used_kb / $size_kb * 100, 1) : null,
'temp' => is_numeric($tempRaw) ? (int)$tempRaw : null,
'transport' => $d['transport'] ?? 'ata',
@@ -785,7 +788,7 @@ function vv_remote_hosts_stats(): array {
$availBytes = (float)($mMem['available'] ?? 0);
$memPct = $totalBytes > 0 ? (int)round(($totalBytes - $availBytes) / $totalBytes * 100) : 0;
}
$memTotalGb = isset($mMem['total']) ? _vv_api_bytes_to_gb((float)$mMem['total']) : 0;
$memTotalGb = isset($mMem['total']) ? _vv_api_bytes_to_gib((float)$mMem['total']) : 0;
$uptimeRaw = $os['uptime'] ?? '';
if (is_numeric($uptimeRaw)) {