Repository navigation
feat: feat(print): copy USB gcode to local storage and print the local copy - #372
Open
gmmcosta15 wants to merge 5 commits into
Open
gmmcosta15 wants to merge 5 commits into
gmmcosta15 wants to merge 5 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Printing a file from a USB drive now copies it into
~/printer_data/gcodes/and prints the local copy, so removing the drive mid-print no longer kills the job. The copy is atomic and only starts printing once Moonraker (and Happy Hare's preprocessor) has finished with it. Reprinting the same USB file reuses the existing local copy instead of making a new one.Changes
lib/utils/usb_import.py: validates the USB path (mounted drive, no symlink or..escape,.gcodeonly), checks free space, copies via a fsynced temp file inprinter_data/.usb_import/andos.replace, runs off the UI thread asUsbImportTask.usb_import/index.jsonmaps each USB file (name, size, head and tail hash) to its processed local copy; byte-identical same-name files are reused too, a different file with the same name gets a_nsuffixprintTab.start_printroutes USB files through the import; a new copy prints after Moonraker'screate_filefor it, or after a 120 s timeoutMotivation
Prints started from a USB drive read the file from the drive for the whole job, so pulling it or a loose connection ended the print. Happy Hare also rewrites new gcodes, so printing before it finishes left Klipper reading a deleted file.