From b369173f94e872139f356ccbb9697a19824cb9a0 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Tue, 21 Dec 2021 12:53:59 -0500 Subject: [PATCH] app: refactor upload handler registration Move upload handler registration out of the file manager. Register the primary hander in the app module, and the Octoprint Comptaiblity handler in octoprint_compat. Signed-off-by: Eric Callahan --- moonraker/app.py | 1 + moonraker/components/file_manager/file_manager.py | 3 --- moonraker/components/octoprint_compat.py | 4 ++++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/moonraker/app.py b/moonraker/app.py index deadbba..9bd419d 100644 --- a/moonraker/app.py +++ b/moonraker/app.py @@ -176,6 +176,7 @@ class MoonrakerApp: "moonraker.log", logfile, force=True) self.register_static_file_handler( "klippy.log", DEFAULT_KLIPPY_LOG_PATH, force=True) + self.register_upload_handler("/server/files/upload") def _get_path_option(self, config: ConfigHelper, option: str) -> str: path: Optional[str] = config.get(option, None) diff --git a/moonraker/components/file_manager/file_manager.py b/moonraker/components/file_manager/file_manager.py index af209e4..aad4e99 100644 --- a/moonraker/components/file_manager/file_manager.py +++ b/moonraker/components/file_manager/file_manager.py @@ -87,9 +87,6 @@ class FileManager: transports=["websocket"]) # register client notificaitons self.server.register_notification("file_manager:filelist_changed") - # Register APIs to handle file uploads - self.server.register_upload_handler("/server/files/upload") - self.server.register_upload_handler("/api/files/local") self.server.register_event_handler( "server:klippy_identified", self._update_fixed_paths) diff --git a/moonraker/components/octoprint_compat.py b/moonraker/components/octoprint_compat.py index a1782c1..e7d5e3e 100644 --- a/moonraker/components/octoprint_compat.py +++ b/moonraker/components/octoprint_compat.py @@ -95,6 +95,10 @@ class OctoprintCompat: '/api/printerprofiles', ['GET'], self._get_printerprofiles, transports=['http'], wrap_result=False) + # Upload Handlers + self.server.register_upload_handler( + "/api/files/local", location_prefix="api/moonraker/files/") + # System # TODO: shutdown/reboot/restart operations