mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-09-13 13:35:43 +03:00
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:
parent
1a307edbca
commit
eb15c7138b
@ -457,7 +457,14 @@ class Project:
|
|||||||
|
|
||||||
# Non-recursive: list only the current directory level
|
# Non-recursive: list only the current directory level
|
||||||
files = []
|
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
|
name = entry.name
|
||||||
rel_path = name if not subpath else os.path.join(subpath, name)
|
rel_path = name if not subpath else os.path.join(subpath, name)
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user