mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-27 07:25:16 +00:00
Fix: close the temp file descriptor when saving mail as eml
This commit is contained in:
1 parent
f775b94cd6
commit
7f80f4608c
1 file changed
+3
-2
@@ -2,6 +2,7 @@ import datetime
|
||||
import imaplib
|
||||
import itertools
|
||||
import logging
|
||||
import os
|
||||
import socket
|
||||
import ssl
|
||||
import tempfile
|
||||
@@ -1135,12 +1136,12 @@ class MailAccountHandler(LoggingMixin):
|
||||
doc_type,
|
||||
):
|
||||
settings.SCRATCH_DIR.mkdir(parents=True, exist_ok=True)
|
||||
_, temp_filename = tempfile.mkstemp(
|
||||
fd, temp_filename = tempfile.mkstemp(
|
||||
prefix="paperless-mail-",
|
||||
dir=settings.SCRATCH_DIR,
|
||||
suffix=".eml",
|
||||
)
|
||||
with Path(temp_filename).open("wb") as f:
|
||||
with os.fdopen(fd, "wb") as f:
|
||||
# Move "From"-header to beginning of file
|
||||
# TODO: This ugly workaround is needed because the parser is
|
||||
# chosen only by the mime_type detected via magic
|
||||
|
||||
Reference in new issue
Block a user