Fix list_node_files PermissionError on os.scandir

Wrap os.scandir() in try-except to return empty list instead of
crashing when a node directory is not readable.
This commit is contained in:
YueGuobin 2026-06-10 00:15:26 +08:00
parent 1a307edbca
commit eb15c7138b
No known key found for this signature in database

View File

@ -457,7 +457,14 @@ class Project:
# Non-recursive: list only the current directory level
files = []
for entry in os.scandir(target_path):
try:
scandir_iter = os.scandir(target_path)
except PermissionError:
return files
except OSError as e:
log.error(f"Error listing node directory '{target_path}': {e}")
return files
for entry in scandir_iter:
name = entry.name
rel_path = name if not subpath else os.path.join(subpath, name)
try: