Skip to content

Commit 3f7b51f

Browse files
committed
TLDR-517 fix attachments handler
1 parent d3c958b commit 3f7b51f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

dedoc/attachments_handler/attachments_handler.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import copy
22
import logging
33
import os
4-
import shutil
5-
import tempfile
64
import time
75
from typing import List
86

@@ -64,12 +62,12 @@ def handle_attachments(self, document_parser: "DedocManager", document: Unstruct
6462

6563
try:
6664
if attachment.need_content_analysis:
67-
with tempfile.TemporaryDirectory() as tmpdir:
68-
attachment_path = os.path.join(tmpdir, attachment.get_original_filename())
69-
shutil.copy(attachment.get_filename_in_path(), attachment_path)
70-
parsed_file = document_parser.parse(attachment_path, parameters=parameters_copy)
65+
parsed_file = document_parser.parse(attachment.get_filename_in_path(), parameters=parameters_copy)
7166
else:
7267
parsed_file = self.__get_empty_document(document_parser=document_parser, attachment=attachment, parameters=parameters_copy)
68+
69+
parsed_file.metadata.file_name = attachment.original_name # initial name of the attachment
70+
parsed_file.metadata.temporary_file_name = os.path.split(attachment.get_filename_in_path())[-1] # actual name in the file system
7371
except DedocError:
7472
# return empty ParsedDocument with Meta information
7573
parsed_file = self.__get_empty_document(document_parser=document_parser, attachment=attachment, parameters=parameters_copy)

0 commit comments

Comments
 (0)