Repository navigation
Keep template PDFs that are still in use when deleting a template - #739
Merged
marcvergees merged 2 commits intoOct 26, 2026
Merged
marcvergees merged 2 commits into
marcvergees merged 2 commits into
Conversation
Deleting a template removed its PDF even when another template pointed at the same file, or when it was the bundled seed PDF, which left the remaining or re-seeded template with a missing file. Fixes fireform-core#738
marcvergees
approved these changes
Oct 26, 2026
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
DELETE /templates/{id}always deleted the template's PDF from disk, even when it was still needed:data/inputs/file_template_manual.pdf, a file tracked in the repo. If the template table was later empty,seed_db()re-created the template on the next start, pointing at a PDF that no longer existed.POST /templates/createaccepts any existingpdf_path, so two templates can point at the same file. Deleting one broke the other.Changes:
app/core/config.py: newSEED_TEMPLATE_PDF_PATHconstant, now used byseed_db()instead of the hard-coded string.app/services/template.py:delete_templateonly unlinks the PDF if_pdf_still_needed()is false. It is "still needed" when it's the seed PDF, or when another template resolves to the same file. Paths are compared after resolving, sodata/inputs/x.pdfand./data/inputs/x.pdfcount as the same file.Everything else about deletion is unchanged: submissions, their output PDFs, and jobs are still removed, and a PDF used only by the deleted template is still deleted (the existing
test_delete_template_deletes_pdf_filestill passes).Fixes #738
Type of change
How Has This Been Tested?
tests/test_deletion.py:test_delete_template_keeps_pdf_shared_with_another_template: two templates share a PDF; deleting the first keeps the file, deleting the second removes ittest_delete_template_keeps_seed_pdf: deleting a template that uses the seed PDF keeps the filedevelopmentand pass with this changepython -m pytest tests/→ 315 passedruff check app/→ all checks passedTest Configuration:
Checklist: