From 31705bb588c738d1573713cba8bbbb3b481246e6 Mon Sep 17 00:00:00 2001 From: Kara Engelhardt Date: Wed, 12 Nov 2025 11:39:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Clear=20Document.pdf=5Ffile=20af?= =?UTF-8?q?ter=20FoiAttachment=20redaction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the pdf_file is set (for example because the document pdf needed to be rewritten and get_writeable_file was called), it will take precedence over the attachments pdf. This means that new redactions applied to the attachment after pdf_file is set are not shown in the document, as the old version from pdf_file is still used for generating the pages etc. --- froide/document/signals.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/froide/document/signals.py b/froide/document/signals.py index 29c981298..f26364c2c 100644 --- a/froide/document/signals.py +++ b/froide/document/signals.py @@ -24,6 +24,9 @@ def document_created(instance=None, created=False, **kwargs): ) def reprocess_document_after_redaction(sender: FoiAttachment, **kwargs): if sender.document and kwargs.get("redacted"): + # Clear pdf_file, it might contain an older version of the redacted file + if sender.document.pdf_file: + sender.document.pdf_file.delete(save=True) # Recreate pages after redaction sender.document.process_document(reprocess=True) return @@ -43,6 +46,8 @@ def reprocess_document_after_redaction(sender: FoiAttachment, **kwargs): FoiAttachment.objects.filter(id=sender.id).update(document_id=doc_id) # Then reprocess document document = Document.objects.get(id=doc_id) + if document.pdf_file: + document.pdf_file.delete(save=True) document.process_document(reprocess=True)