mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Fix: use temp dir for split / merge (#7105)
This commit is contained in:
parent
f3b7ae93f0
commit
f3cf608caa
@ -2,6 +2,7 @@ import hashlib
|
|||||||
import itertools
|
import itertools
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import tempfile
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from celery import chain
|
from celery import chain
|
||||||
@ -269,7 +270,7 @@ def merge(
|
|||||||
return "OK"
|
return "OK"
|
||||||
|
|
||||||
filepath = os.path.join(
|
filepath = os.path.join(
|
||||||
settings.SCRATCH_DIR,
|
tempfile.mkdtemp(dir=settings.SCRATCH_DIR),
|
||||||
f"{'_'.join([str(doc_id) for doc_id in doc_ids])[:100]}_merged.pdf",
|
f"{'_'.join([str(doc_id) for doc_id in doc_ids])[:100]}_merged.pdf",
|
||||||
)
|
)
|
||||||
merged_pdf.remove_unreferenced_resources()
|
merged_pdf.remove_unreferenced_resources()
|
||||||
@ -321,7 +322,7 @@ def split(doc_ids: list[int], pages: list[list[int]], delete_originals: bool = F
|
|||||||
for page in split_doc:
|
for page in split_doc:
|
||||||
dst.pages.append(pdf.pages[page - 1])
|
dst.pages.append(pdf.pages[page - 1])
|
||||||
filepath = os.path.join(
|
filepath = os.path.join(
|
||||||
settings.SCRATCH_DIR,
|
tempfile.mkdtemp(dir=settings.SCRATCH_DIR),
|
||||||
f"{doc.id}_{split_doc[0]}-{split_doc[-1]}.pdf",
|
f"{doc.id}_{split_doc[0]}-{split_doc[-1]}.pdf",
|
||||||
)
|
)
|
||||||
dst.remove_unreferenced_resources()
|
dst.remove_unreferenced_resources()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user