mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-27 07:25:16 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4ddedcb34 |
No files matched your search
@@ -364,13 +364,14 @@ def extract_pdf_metadata(
|
||||
namespace_pattern = re.compile(r"\{(.*)\}(.*)")
|
||||
|
||||
try:
|
||||
pdf = pikepdf.open(document_path)
|
||||
meta = pdf.open_metadata()
|
||||
with pikepdf.open(document_path) as pdf:
|
||||
meta = pdf.open_metadata()
|
||||
items = list(meta.items())
|
||||
except Exception as e:
|
||||
_log.warning("Could not open PDF metadata for %s: %s", document_path, e)
|
||||
return []
|
||||
|
||||
for key, value in meta.items():
|
||||
for key, value in items:
|
||||
if isinstance(value, list):
|
||||
value = " ".join(str(e) for e in value)
|
||||
value = str(value)
|
||||
|
||||
@@ -2,7 +2,6 @@ import datetime
|
||||
import imaplib
|
||||
import itertools
|
||||
import logging
|
||||
import os
|
||||
import socket
|
||||
import ssl
|
||||
import tempfile
|
||||
@@ -1136,12 +1135,12 @@ class MailAccountHandler(LoggingMixin):
|
||||
doc_type,
|
||||
):
|
||||
settings.SCRATCH_DIR.mkdir(parents=True, exist_ok=True)
|
||||
fd, temp_filename = tempfile.mkstemp(
|
||||
_, temp_filename = tempfile.mkstemp(
|
||||
prefix="paperless-mail-",
|
||||
dir=settings.SCRATCH_DIR,
|
||||
suffix=".eml",
|
||||
)
|
||||
with os.fdopen(fd, "wb") as f:
|
||||
with Path(temp_filename).open("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