mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-18 03:41:24 +00:00
Ensure reindex happens after extraction on manual runs
This commit is contained in:
6 files changed
+110
-23
No files matched your search
+15
-15
@@ -376,22 +376,22 @@ def extract_zones(document_id: int, template_id: int | None = None) -> None:
|
||||
matches it when no template is given.
|
||||
"""
|
||||
document = Document.objects.get(id=document_id)
|
||||
if template_id is None:
|
||||
run_zone_extraction(document, None)
|
||||
return
|
||||
templates = None
|
||||
if template_id is not None:
|
||||
try:
|
||||
template = OcrTemplate.objects.prefetch_related(
|
||||
"zones",
|
||||
"zones__custom_field",
|
||||
).get(id=template_id)
|
||||
except OcrTemplate.DoesNotExist:
|
||||
logger.warning(
|
||||
"OCR template %s no longer exists, not running zone OCR",
|
||||
template_id,
|
||||
)
|
||||
return
|
||||
templates = [template]
|
||||
|
||||
try:
|
||||
template = OcrTemplate.objects.prefetch_related(
|
||||
"zones",
|
||||
"zones__custom_field",
|
||||
).get(id=template_id)
|
||||
except OcrTemplate.DoesNotExist:
|
||||
logger.warning(
|
||||
"OCR template %s no longer exists, not running zone OCR",
|
||||
template_id,
|
||||
)
|
||||
return
|
||||
run_zone_extraction(document, None, templates=[template])
|
||||
run_zone_extraction(document, templates=templates, reindex=True)
|
||||
|
||||
|
||||
@shared_task
|
||||
|
||||
Reference in new issue
Block a user