1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-20 10:28:45 +00:00

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
This commit is contained in:
Stefan Agner
2025-11-25 10:00:46 +01:00
committed by GitHub
parent 7244e447ab
commit 032fa4cdc4

View File

@@ -347,6 +347,10 @@ class APIHost(CoreSysAttributes):
disk.disk_usage, self.sys_config.path_supervisor 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( known_paths = await self.sys_run_in_executor(
disk.get_dir_sizes, disk.get_dir_sizes,
{ {
@@ -365,13 +369,12 @@ class APIHost(CoreSysAttributes):
"id": "root", "id": "root",
"label": "Root", "label": "Root",
"total_bytes": total, "total_bytes": total,
"used_bytes": total - free, "used_bytes": used,
"children": [ "children": [
{ {
"id": "system", "id": "system",
"label": "System", "label": "System",
"used_bytes": total "used_bytes": used
- free
- sum(path["used_bytes"] for path in known_paths), - sum(path["used_bytes"] for path in known_paths),
}, },
*known_paths, *known_paths,