1
mirror of https://github.com/home-assistant/core synced 2024-08-28 03:36:46 +02:00

Handle no permission for disks in Systemmonitor (#106653)

This commit is contained in:
G Johansson 2023-12-29 13:21:36 +01:00 committed by GitHub
parent 4cd1965786
commit 853e4d87fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,13 @@ def get_all_disk_mounts() -> set[str]:
# ENOENT, pop-up a Windows GUI error for a non-ready
# partition or just hang.
continue
usage = psutil.disk_usage(part.mountpoint)
try:
usage = psutil.disk_usage(part.mountpoint)
except PermissionError:
_LOGGER.debug(
"No permission for running user to access %s", part.mountpoint
)
continue
if usage.total > 0 and part.device != "":
disks.add(part.mountpoint)
_LOGGER.debug("Adding disks: %s", ", ".join(disks))