From b291d945960ae835a68d0f4e405e971ed6899148 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Sat, 5 Nov 2022 10:48:50 -0400 Subject: [PATCH] file_manager: implement additional reserved path filters Do not add inotify watches for reserved paths that exclude write acccess. Do not return include reserved paths in file list requests without read access. Signed-off-by: Eric Callahan --- moonraker/components/file_manager/file_manager.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/moonraker/components/file_manager/file_manager.py b/moonraker/components/file_manager/file_manager.py index 6e27bda..bb4df0a 100644 --- a/moonraker/components/file_manager/file_manager.py +++ b/moonraker/components/file_manager/file_manager.py @@ -748,7 +748,8 @@ class FileManager: key = (st.st_dev, st.st_ino) if key not in visited_dirs: visited_dirs.add(key) - scan_dirs.append(dname) + if not self.check_reserved_path(full_path, False, False): + scan_dirs.append(dname) dir_names[:] = scan_dirs for name in files: ext = os.path.splitext(name)[-1].lower() @@ -915,6 +916,9 @@ class InotifyNode: for fname in os.listdir(dir_path): item_path = os.path.join(dir_path, fname) if os.path.isdir(item_path): + fm = self.ihdlr.file_manager + if fm.check_reserved_path(item_path, True, False): + continue new_child = self.create_child_node(fname, False) if new_child is not None: metadata_events.extend(new_child.scan_node(visited_dirs))