mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-08 06:26:08 +01:00
Creates a data model for the document consumption, allowing stronger typing of arguments and setting of some information about the file only once
This commit is contained in:
parent
fa60251c18
commit
3c2bbf244d
14 changed files with 596 additions and 433 deletions
|
|
@ -13,6 +13,9 @@ from typing import Set
|
|||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.management.base import CommandError
|
||||
from documents.data_models import ConsumableDocument
|
||||
from documents.data_models import DocumentMetadataOverrides
|
||||
from documents.data_models import DocumentSource
|
||||
from documents.models import Tag
|
||||
from documents.parsers import is_file_ext_supported
|
||||
from documents.tasks import consume_file
|
||||
|
|
@ -122,8 +125,11 @@ def _consume(filepath: str) -> None:
|
|||
try:
|
||||
logger.info(f"Adding {filepath} to the task queue.")
|
||||
consume_file.delay(
|
||||
filepath,
|
||||
override_tag_ids=list(tag_ids) if tag_ids else None,
|
||||
ConsumableDocument(
|
||||
source=DocumentSource.ConsumeFolder,
|
||||
original_file=filepath,
|
||||
),
|
||||
DocumentMetadataOverrides(tag_ids=tag_ids),
|
||||
)
|
||||
except Exception:
|
||||
# Catch all so that the consumer won't crash.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue