Chore: Structured consume task return values (#12612)

This commit is contained in:
Trenton H authored and GitHub committed 2026-04-20 13:19:54 -07:00
1 parent 7492cda794
commit 58789e5061
15 files changed
+125 -82

No files matched your search

+24
View File
@@ -2,6 +2,7 @@ import dataclasses
import datetime
from enum import IntEnum
from pathlib import Path
from typing import TypedDict
import magic
from guardian.shortcuts import get_groups_with_perms
@@ -184,3 +185,26 @@ class ConsumableDocument:
# Get the file type once at init
# Note this function isn't called when the object is unpickled
self.mime_type = magic.from_file(self.original_file, mime=True)
class ConsumeFileDuplicateResult(TypedDict):
"""Returned by consume_file when the file is rejected as a duplicate."""
duplicate_of: int
duplicate_in_trash: bool
class ConsumeFileSuccessResult(TypedDict):
"""Returned by consume_file when the document is created successfully."""
document_id: int
class ConsumeFileStoppedResult(TypedDict):
"""Returned by consume_file when a plugin raises StopConsumeTaskError.
Examples: barcode split dispatched child tasks, double-sided scan waiting
for the second half, workflow deleted the document during consumption.
"""
reason: str