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 Franck Nijhof
parent 767c55fbac
commit 494dd2ef07
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

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))