moonraker
moonraker copied to clipboard
file_manager: Added event for metadata update
I'm working on a component that should do some work after a file's metadata has been updated. This PR adds an event that fires when a file's metadata has been successfully parsed and updated.
Signed-off-by: Kieran Eglin [email protected]
Great idea. Lots of uses
@Arksine is it possible to request a review here? I would also like to confirm whether the fname variable I'm passing would contain the full file path or just the file name without any directory information. If it's the latter, I'll need to update this to include that information
Thanks, sorry for the delay. I do have a few observations:
-
Previously Moonraker did emit a metadata update event, however it was removed after inotify support was added as it was not longer required. The
file_manager:filelist_changedevent triggers after metadata processing is complete, so remote clients may use that to perform operations that require metadata to be present. It is possible to filter using thecreate_fileandcreate_diractions on items within thegcodesroot. Thecreate_diraction indicates that a new folder has been created OR a folder has been copied. In the case of the latter metadata for all items within the folder has been processed. -
The filename is relative to the
gcodesroot. So for example if the file's full path is/home/pi/printer_data/gcodes/test_prints/cube.gcodethen thefnamewill betest_prints/cube.gcode. -
Since this event isn't being emitted as a notification we dont need to wrap it within a
dictobject. It might be better to pass two arguments, the first being the filename, the second being the metadata itself. -
I'm not opposed to reintroducing a metadata event, however before merging there needs to be code within Moonraker to provide a rational basis for merging it. Additionally I'm currently reworking parts of how Moonraker handles metadata internally, so there is a possibility that this event could be refactored.