From 032fa4cdc43532b88c724fef35c49c080e23e5ba Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Tue, 25 Nov 2025 10:00:46 +0100 Subject: [PATCH] Add comment to explicit "used" calculation for disk usage API (#6340) * Add explicit used calculation for disk usage API Added explicit calculation for used disk space along with a comment to clarify the reasoning behind the calculation method. * Address review feedback --- supervisor/api/host.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/supervisor/api/host.py b/supervisor/api/host.py index c799e116b..ea197bf8f 100644 --- a/supervisor/api/host.py +++ b/supervisor/api/host.py @@ -347,6 +347,10 @@ class APIHost(CoreSysAttributes): disk.disk_usage, self.sys_config.path_supervisor ) + # Calculate used by subtracting free makes sure we include reserved space + # in used space reporting. + used = total - free + known_paths = await self.sys_run_in_executor( disk.get_dir_sizes, { @@ -365,13 +369,12 @@ class APIHost(CoreSysAttributes): "id": "root", "label": "Root", "total_bytes": total, - "used_bytes": total - free, + "used_bytes": used, "children": [ { "id": "system", "label": "System", - "used_bytes": total - - free + "used_bytes": used - sum(path["used_bytes"] for path in known_paths), }, *known_paths,