A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Use the attachment filename so downstream template matching works against it (#4931)
Trenton Hfbf1a051a250
diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.pyindex 0b6ec316f..906aafa15 100644--- a/src/paperless_mail/mail.py+++ b/src/paperless_mail/mail.py@@ -8,6 +8,7 @@ import tracebackfrom datetime import datefrom datetime import timedeltafrom fnmatch import fnmatch+from pathlib import Pathfrom typing import Optionalfrom typing import Union@@ -703,12 +704,15 @@ class MailAccountHandler(LoggingMixin):if is_mime_type_supported(mime_type):os.makedirs(settings.SCRATCH_DIR, exist_ok=True)- _, temp_filename = tempfile.mkstemp(- prefix="paperless-mail-",- dir=settings.SCRATCH_DIR,++ temp_dir = Path(+ tempfile.mkdtemp(+ prefix="paperless-mail-",+ dir=settings.SCRATCH_DIR,+ ),)- with open(temp_filename, "wb") as f:- f.write(att.payload)+ temp_filename = temp_dir / pathvalidate.sanitize_filename(att.filename)+ temp_filename.write_bytes(att.payload)self.log.info(f"Rule {rule}: "diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.pyindex 55983939a..8488ac65d 100644--- a/src/paperless_mail/tests/test_mail.py+++ b/src/paperless_mail/tests/test_mail.py@@ -1271,7 +1271,10 @@ class TestMail(self.assertEqual(len(self.bogus_mailbox.fetch("UNSEEN", False)), 0)self.assertEqual(len(self.bogus_mailbox.messages), 3)- def assert_queue_consumption_tasks_call_args(self, expected_call_args: list):+ def assert_queue_consumption_tasks_call_args(+ self,+ expected_call_args: list[list[dict[str, str]]],+ ):"""Verifies that queue_consumption_tasks has been called with the expected arguments.@@ -1283,7 +1286,7 @@ class TestMail("""- # assert number of calls to queue_consumption_tasks mathc+ # assert number of calls to queue_consumption_tasks matchself.assertEqual(len(self._queue_consumption_tasks_mock.call_args_list),len(expected_call_args),