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 <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-03-14 18:23:27 -04:00
parent a5c455a305
commit 62012726da
1 changed files with 5 additions and 0 deletions

View File

@ -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)