Skip to content

Commit a863d00

Browse files
authored
fix [Errno 13] Permission denied in windows (#5622)
* fix [Errno 13] Permission denied in windows * formatting code * formatting code
1 parent 156bf88 commit a863d00

File tree

1 file changed

+5
-1
lines changed
  • pipelines/pipelines/nodes/file_converter

1 file changed

+5
-1
lines changed

pipelines/pipelines/nodes/file_converter/pdf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,13 @@ def convert(
209209
try:
210210
images = convert_from_path(file_path)
211211
for image in images:
212-
temp_img = tempfile.NamedTemporaryFile(dir=os.path.dirname(os.path.realpath(__file__)), suffix=".jpeg")
212+
temp_img = tempfile.NamedTemporaryFile(
213+
dir=os.path.dirname(os.path.realpath(__file__)), suffix=".jpeg", delete=False
214+
)
213215
image.save(temp_img.name)
214216
pages.append(self.image_2_text.convert(temp_img.name)[0]["content"])
217+
temp_img.close()
218+
os.remove(temp_img.name)
215219
except Exception as exception:
216220
logger.error(f"File {file_path} has an error \n {exception}")
217221

0 commit comments

Comments
 (0)