mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-15 02:57:09 +01:00
Use the attachment filename so downstream template matching works against it (#4931)
This commit is contained in:
parent
7ecf7f704a
commit
fbf1a051a2
2 changed files with 14 additions and 7 deletions
|
|
@ -8,6 +8,7 @@ import traceback
|
|||
from datetime import date
|
||||
from datetime import timedelta
|
||||
from fnmatch import fnmatch
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from 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}: "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue