I want to add functionality to switch out the current print, mid print.
My usecase is for someone who is mid way through printing some item, and they decide they want to change some options - for example, adjust the infill density, the layer height, or they have realised the house they are printing really needs a chimney!
The user interface, for example from Cura, which has octoprint integration, would involve the user adjusting the settings they want to change, then clicking "print" again. If the filename currently being printed matches the filename of the new document, then cura would pop up a dialog saying "Print already in progress. Either abort the print and start again, or modify remainder of existing print. [Abort] [Modify]".
Implementation-wise, the octoprint POST /api/files/local
API would be updated to allow the currently printing file to be uploaded again (it currently returns an error). The API call would have an extra field added called modify_print_changeover_marker
. This is a string that uniquely exists in both the original file, and the modified file. For example ;Layer:57
. At that point in the print, octoprint would switch from the old file to the new. It would be up to the slicer software to decide what markers to insert and where.
If the marker had already been passed, octoprint would return an error. The error would contain the current byte position in the file, allowing the client to retry with a later marker. If the client desires, they can leave out the content of the uploaded file, and get an error response which also includes the current byte position in the file, allowing the client to avoid double-uploading the data.
So... Is the above design reasonable? It tries to touch as few components as possible to enable the usecase. Are there better approaches?