From 62012726daaa7d0bf100919fe183ea0696c38417 Mon Sep 17 00:00:00 2001 From: Arksine Date: Sun, 14 Mar 2021 18:23:27 -0400 Subject: [PATCH] file_manager: add a "check_file_exists" method Other modules may look up this plugin to determine if a particular file exists at the specified root. Signed-off-by: Eric Callahan --- moonraker/plugins/file_manager.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/moonraker/plugins/file_manager.py b/moonraker/plugins/file_manager.py index aa924bb..fe50af2 100644 --- a/moonraker/plugins/file_manager.py +++ b/moonraker/plugins/file_manager.py @@ -139,6 +139,11 @@ class FileManager: def get_fixed_path_args(self): return dict(self.fixed_path_args) + def check_file_exists(self, root, filename): + root_dir = self.file_paths.get(root, "") + file_path = os.path.join(root_dir, filename) + return os.path.exists(file_path) + async def _handle_filelist_request(self, web_request): root = web_request.get_str('root', "gcodes") return self.get_file_list(root, list_format=True, notify=True)