diff --git a/src/documents/barcodes.py b/src/documents/barcodes.py index fe1e94b8a..e68ba4f8c 100644 --- a/src/documents/barcodes.py +++ b/src/documents/barcodes.py @@ -100,11 +100,9 @@ class BarcodePlugin(ConsumeTaskPlugin): logger.info(f"Found tags in barcode: {tags}") # Lastly attempt to split documents - if settings.CONSUMER_ENABLE_BARCODES: - - separator_pages = self.get_separation_pages() - if not separator_pages: - return "No pages to split on!" + if settings.CONSUMER_ENABLE_BARCODES and ( + separator_pages := self.get_separation_pages() + ): # We have pages to split against diff --git a/src/documents/tests/test_barcodes.py b/src/documents/tests/test_barcodes.py index 732c2e167..2f4f5cd39 100644 --- a/src/documents/tests/test_barcodes.py +++ b/src/documents/tests/test_barcodes.py @@ -15,6 +15,7 @@ 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.plugins.base import StopConsumeTaskError from documents.tests.utils import DirectoriesMixin from documents.tests.utils import DocumentConsumeDelayMixin from documents.tests.utils import DummyProgressManager @@ -415,7 +416,10 @@ class TestBarcode( test_file = self.SAMPLE_DIR / "simple.pdf" 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( CONSUMER_ENABLE_BARCODES=True,