From 4830ac53c758118f272c818ce548ebdde3f0894e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 23 Oct 2023 18:25:26 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20operation=20to=20FileRemoved?= =?UTF-8?q?=20event?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also document operation field for FileAdded. --- docs/events/index.rst | 2 ++ src/octoprint/filemanager/__init__.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docs/events/index.rst b/docs/events/index.rst index 2ef7d2d70..71c8dcc2b 100644 --- a/docs/events/index.rst +++ b/docs/events/index.rst @@ -246,6 +246,7 @@ FileAdded * ``name``: the file's name * ``type``: the file's type, a list of the path within the type hierarchy, e.g. ``["machinecode", "gcode"]`` or ``["model", "stl"]`` + * ``operation``: the operation that triggered the event, either ``add``, ``copy`` or ``move``. .. note:: @@ -263,6 +264,7 @@ FileRemoved * ``name``: the file's name * ``type``: the file's type, a list of the path within the type hierarchy, e.g. ``["machinecode", "gcode"]`` or ``["model", "stl"]`` + * ``operation``: the operation that triggered the event, either ``remove`` or ``move`` .. note:: diff --git a/src/octoprint/filemanager/__init__.py b/src/octoprint/filemanager/__init__.py index ba9e760d7..2fb8f31f4 100644 --- a/src/octoprint/filemanager/__init__.py +++ b/src/octoprint/filemanager/__init__.py @@ -769,6 +769,7 @@ class FileManager: "path": path, "name": name, "type": get_file_type(name), + "operation": "remove", }, ) eventManager().fire(Events.UPDATED_FILES, {"type": "printables"}) @@ -814,6 +815,7 @@ class FileManager: "path": source_path_in_storage, "name": source_name, "type": get_file_type(source_name), + "operation": "move", }, ) eventManager().fire(