mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 22:11:14 +02: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:
1 file changed
+8
-1
@@ -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:
|
||||||
|
|||||||
Reference in new issue
Block a user