mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-20 10:28:45 +00:00
Ignore missing files when counting used space (#6174)
This commit is contained in:
@@ -99,18 +99,16 @@ class HwDisk(CoreSysAttributes):
|
|||||||
root_device = path.stat().st_dev
|
root_device = path.stat().st_dev
|
||||||
|
|
||||||
for child in path.iterdir():
|
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
|
# Skip symlinks to avoid infinite loops
|
||||||
if child.is_symlink():
|
if child.is_symlink():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Skip if not on same device (external mount)
|
stat = child.stat(follow_symlinks=False)
|
||||||
if child.stat().st_dev != root_device:
|
except FileNotFoundError:
|
||||||
continue
|
# File might disappear between listing and stat, ignore
|
||||||
|
_LOGGER.warning("File not found: %s", child.as_posix())
|
||||||
|
continue
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
if err.errno == errno.EBADMSG:
|
if err.errno == errno.EBADMSG:
|
||||||
self.sys_resolution.add_unhealthy_reason(
|
self.sys_resolution.add_unhealthy_reason(
|
||||||
@@ -119,6 +117,13 @@ class HwDisk(CoreSysAttributes):
|
|||||||
break
|
break
|
||||||
continue
|
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)
|
child_result = self.get_dir_structure_sizes(child, max_depth - 1)
|
||||||
if child_result["used_bytes"] > 0:
|
if child_result["used_bytes"] > 0:
|
||||||
size += child_result["used_bytes"]
|
size += child_result["used_bytes"]
|
||||||
|
|||||||
Reference in New Issue
Block a user