From 517349c3afd1f29451971d537099476f656a2556 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 26 Jan 2026 17:17:41 -0800 Subject: [PATCH] Use mkstemp --- src/documents/tasks.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/documents/tasks.py b/src/documents/tasks.py index 5e710d2d6..fc8911705 100644 --- a/src/documents/tasks.py +++ b/src/documents/tasks.py @@ -5,8 +5,8 @@ import shutil import uuid import zipfile from pathlib import Path -from tempfile import NamedTemporaryFile from tempfile import TemporaryDirectory +from tempfile import mkstemp import tqdm from celery import Task @@ -663,12 +663,8 @@ def build_share_link_bundle(bundle_id: int): documents = list(bundle.documents.all().order_by("pk")) - with NamedTemporaryFile( - dir=settings.SCRATCH_DIR, - suffix=".zip", - delete=False, - ) as temp_zip: - temp_zip_path = Path(temp_zip.name) + _, temp_zip_path_str = mkstemp(suffix=".zip", dir=settings.SCRATCH_DIR) + temp_zip_path = Path(temp_zip_path_str) try: strategy_class = (