Fix: create the scratch dir before zone OCR renders into it

This commit is contained in:
stumpylog committed 2026-11-20 09:38:50 -08:00
1 parent 5182b719c5
commit 0348dc532f
2 files changed
+3

No files matched your search

+1
View File
@@ -5926,6 +5926,7 @@ class OcrTemplateViewSet(BulkPermissionMixin, PassUserMixin, ModelViewSet[OcrTem
content_type=file_doc.mime_type,
)
settings.SCRATCH_DIR.mkdir(parents=True, exist_ok=True)
with tempfile.TemporaryDirectory(dir=settings.SCRATCH_DIR) as tmp_dir:
rendered = Path(tmp_dir) / "page.png"
try:
+2
View File
@@ -339,6 +339,7 @@ def plan_zone_extraction(
if not pages:
return []
plans = []
settings.SCRATCH_DIR.mkdir(parents=True, exist_ok=True)
with tempfile.TemporaryDirectory(dir=settings.SCRATCH_DIR) as tmp_dir:
tmp_path = Path(tmp_dir)
page_images = _render_pages(
@@ -849,6 +850,7 @@ def extract_zone_preview(
) -> ZoneExtraction:
"""Extract a zone without writing its value to the document."""
page_idx = _resolve_page_idx(zone.page, page_count)
settings.SCRATCH_DIR.mkdir(parents=True, exist_ok=True)
with tempfile.TemporaryDirectory(dir=settings.SCRATCH_DIR) as tmp_dir:
tmp_path = Path(tmp_dir)
page_images = _render_pages(