From 3fa47fb7a2f3b856a2a82dcf9167401a4b409345 Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Thu, 26 Nov 2026 13:30:58 -0800 Subject: [PATCH] Chore: copy PDFs on disk instead of reading them into memory --- src/paperless/parsers/mail.py | 2 +- src/paperless/parsers/tesseract.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/paperless/parsers/mail.py b/src/paperless/parsers/mail.py index 1b96982ad..4728fe75a 100644 --- a/src/paperless/parsers/mail.py +++ b/src/paperless/parsers/mail.py @@ -566,7 +566,7 @@ class MailDocumentParser: # If no HTML content, create the PDF from the message. # Otherwise, create 2 PDFs and merge them with Gotenberg. if not mail_message.html: - archive_path.write_bytes(mail_pdf_file.read_bytes()) + shutil.copyfile(mail_pdf_file, archive_path) else: pdf_of_html_content = self.generate_pdf_from_html( mail_message.html, diff --git a/src/paperless/parsers/tesseract.py b/src/paperless/parsers/tesseract.py index 7cae31e0a..4548826c5 100644 --- a/src/paperless/parsers/tesseract.py +++ b/src/paperless/parsers/tesseract.py @@ -443,7 +443,7 @@ class RasterisedDocumentParser: self.log.warning( f"PDF/A metadata stamping failed ({e!s}); falling back to plain PDF.", ) - pdfa_path.write_bytes(plain_pdf_path.read_bytes()) + shutil.copyfile(plain_pdf_path, pdfa_path) return pdfa_path