mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-06-25 14:54:18 +00:00
Chore: Structured consume task return values (#12612)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user