Skip to content

Spooling doesn't trigger Event.UPLOAD #6

Closed
@smartin015

Description

@smartin015

I'm the owner of the Continuous Print plugin for OctoPrint and an avid user of Kiri:Moto for slicing and spooling files. My plugin automatically adds uploaded files to a print queue, which is triggered by listening to the UPLOAD event that fires when a file is uploaded via the REST API. All "typical" file upload paths (drag & drop, clicking the Upload button, API call from e.g. PrusaSlicer) go through the REST API in this way.

However, the GridSpace plugin uses self._file_manager.add_file, which bypasses the API and doesn't fire this event. FILE_ADDED does fire transitively due to adding the file, but this event is too generic - it also happens whenever a file is copied or moved, so is not sufficient for detecting when a new gcode file is added with the likely intent for it to be printed.

I'd like to contribute a PR to increase compatibility with other plugins that want to perform actions when KM spools new files. What do you think about one of these options:

  1. Spoof an Events.UPLOAD event firing when a spooled file is saved, basically copying from here. This would maximize compatibility with other plugins, but is a bit sneaky and may bitrot if there are changes to OctoPrint's use of the UPLOAD event.
  2. Create and fire a custom KIRI_MOTO_FILE_UPLOAD event. This adds more boilerplate to the GridSpace plugin and requires individual plugins to integrate specifically with the GridSpace plugin to receive the event, but gives you full control over the event life cycle.
  3. Make a web request to the REST API to upload the file after it's spooled to disk (rather than using filemanager.add_file). This seems really redundant/clunky and I'd prefer not to go this route.

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions