Repository navigation
Removes the temporary files that stopped exports leave beside plots - #3616
Merged
HakanSeven12 merged 2 commits intoNov 24, 2026
Merged
Conversation
The DWF, PDF and SVG exports and the PDF of PUBLISH write to a temporary file beside the output and then replace the output with it. When the process ends during the write, the temporary file stays. After each successful replace, the four writers now call remove_stale_save_temps, as a save does since HakanSeven12#3597: the temporary files of earlier exports to the same file that nothing wrote to for an hour are removed. Co-Authored-By: Claude
One test for each writer: DWF, SVG, PDF and the PDF of PUBLISH. Each puts the temporary file of an export that stopped two hours ago beside the output, exports, and checks that the output exists and the temporary file is gone. The helper stopped_save_temp (test builds only) writes that file. Co-Authored-By: Claude
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.
Change summary
The DWF, PDF and SVG exports and the PDF of PUBLISH write to a temporary file beside the output,
.<name>.ocs-save-<process id>-<n>.<extension>, and then replace the output with it. When the process ends during the write (an abort, a forced quit, a power loss), the temporary file stays. #3597 made a successful save remove such files of its drawing; the exports do not, so the file of a stopped export stays in the folder. A PUBLISH set of many sheets can make a large file.With this change, each successful export removes the temporary files of earlier exports to the same file that nothing has written to for an hour. It is the same cleanup as for a save (
remove_stale_save_temps).What specifically changed
Two commits: the change, then its tests.
src/io/dwf_export.rs(export_dwf_pages),src/io/svg_export.rs(write_svg_atomically),src/io/pdf_export.rs(write_pdf_atomically),src/io/pdf_publish.rs(PublishPdf::finish): after the replace succeeds, each callsremove_stale_save_temps(path). These are all the callers ofreplace_save_fileother than the save, which calls it already.<stem>-1.svg,<stem>-2.svg, ...; each page file cleans its own temporary files.src/io/mod.rs: the doc comment ofremove_stale_save_tempsnames the exports too. The tests commit addsstopped_save_temp(path)(test builds only), which writes the temporary file of a save or export ofpaththat stopped two hours ago.Testing
On main
063aea515.a_dwf_export_removes_the_temporary_file_of_a_stopped_export,an_svg_export_removes_the_temporary_file_of_a_stopped_export,a_pdf_export_removes_the_temporary_file_of_a_stopped_export,a_published_set_removes_the_temporary_file_of_a_stopped_publish. Each puts the temporary file of a stopped export beside the output, exports, and checks that the output exists and the temporary file is gone. Each fails without the change: the temporary file stays. The test of Removes the temporary files that stopped saves leave beside drawings #3597 covers which files the cleanup keeps (younger files, other drawings, other names).cargo test --workspace --locked --no-fail-fast,cargo check --workspace --all-targets, clippy, the wasm32 check, rustfmt on the changed files, the golden file): 8,159 passed and 0 failed before; 8,163 passed and 0 failed after. The 4 new tests are the only difference. Warnings, the wasm32 check, clippy and the golden file are the same. Three of the five files have rustfmt drift on main; this change adds none.cargo mutantson the changed lines: 5 mutants, 5 caught, 0 missed.Not covered
Impact to Contributors
None.
Co-Authored-By: Claude