From b3af22f04894e947870a0ae95b55cb8a625400cd Mon Sep 17 00:00:00 2001 From: Petar Petrov Date: Tue, 9 Sep 2025 14:39:06 +0300 Subject: [PATCH] Ignore missing files when counting used space (#6174) --- supervisor/hardware/disk.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/supervisor/hardware/disk.py b/supervisor/hardware/disk.py index 351768223..90dc1e5a2 100644 --- a/supervisor/hardware/disk.py +++ b/supervisor/hardware/disk.py @@ -99,18 +99,16 @@ class HwDisk(CoreSysAttributes): root_device = path.stat().st_dev for child in path.iterdir(): - if not child.is_dir(): - size += child.stat(follow_symlinks=False).st_size - continue - # Skip symlinks to avoid infinite loops if child.is_symlink(): continue try: - # Skip if not on same device (external mount) - if child.stat().st_dev != root_device: - continue + stat = child.stat(follow_symlinks=False) + except FileNotFoundError: + # File might disappear between listing and stat, ignore + _LOGGER.warning("File not found: %s", child.as_posix()) + continue except OSError as err: if err.errno == errno.EBADMSG: self.sys_resolution.add_unhealthy_reason( @@ -119,6 +117,13 @@ class HwDisk(CoreSysAttributes): break continue + if stat.st_dev != root_device: + continue + + if not child.is_dir(): + size += stat.st_size + continue + child_result = self.get_dir_structure_sizes(child, max_depth - 1) if child_result["used_bytes"] > 0: size += child_result["used_bytes"]