Fixes the interaction when both splitting and ASN are enabled (#5779)

This commit is contained in:
Trenton H 2024-02-15 09:33:26 -08:00 committed by GitHub
parent f6ddcfa839
commit 8d664fad56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View File

@ -100,11 +100,9 @@ class BarcodePlugin(ConsumeTaskPlugin):
logger.info(f"Found tags in barcode: {tags}") logger.info(f"Found tags in barcode: {tags}")
# Lastly attempt to split documents # Lastly attempt to split documents
if settings.CONSUMER_ENABLE_BARCODES: if settings.CONSUMER_ENABLE_BARCODES and (
separator_pages := self.get_separation_pages()
separator_pages = self.get_separation_pages() ):
if not separator_pages:
return "No pages to split on!"
# We have pages to split against # We have pages to split against

View File

@ -15,6 +15,7 @@ from documents.data_models import ConsumableDocument
from documents.data_models import DocumentMetadataOverrides from documents.data_models import DocumentMetadataOverrides
from documents.data_models import DocumentSource from documents.data_models import DocumentSource
from documents.models import Tag from documents.models import Tag
from documents.plugins.base import StopConsumeTaskError
from documents.tests.utils import DirectoriesMixin from documents.tests.utils import DirectoriesMixin
from documents.tests.utils import DocumentConsumeDelayMixin from documents.tests.utils import DocumentConsumeDelayMixin
from documents.tests.utils import DummyProgressManager from documents.tests.utils import DummyProgressManager
@ -415,7 +416,10 @@ class TestBarcode(
test_file = self.SAMPLE_DIR / "simple.pdf" test_file = self.SAMPLE_DIR / "simple.pdf"
with self.get_reader(test_file) as reader: with self.get_reader(test_file) as reader:
self.assertEqual("No pages to split on!", reader.run()) try:
reader.run()
except StopConsumeTaskError:
self.fail("Barcode reader split pages unexpectedly")
@override_settings( @override_settings(
CONSUMER_ENABLE_BARCODES=True, CONSUMER_ENABLE_BARCODES=True,