]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Enhancement: support workflow path matching of barcode-split documents (#10723)
authorDerRockWolf <50499906+DerRockWolf@users.noreply.github.com>
Wed, 24 Sep 2025 21:03:03 +0000 (23:03 +0200)
committerGitHub <noreply@github.com>
Wed, 24 Sep 2025 21:03:03 +0000 (21:03 +0000)
src/documents/barcodes.py
src/documents/data_models.py
src/documents/matching.py
src/documents/tests/test_barcodes.py

index 6742e67043215d8a939e568bf7b78846b5481eef..9054475f44da1447c342c5d66551901dd8bbcb99 100644 (file)
@@ -164,6 +164,9 @@ class BarcodePlugin(ConsumeTaskPlugin):
                         mailrule_id=self.input_doc.mailrule_id,
                         # Can't use same folder or the consume might grab it again
                         original_file=(tmp_dir / new_document.name).resolve(),
+                        # Adding optional original_path for later uses in
+                        # workflow matching
+                        original_path=self.input_doc.original_file,
                     ),
                     # All the same metadata
                     self.metadata,
index fbba36dccdad039f416cfcadd032f2c43eb1e5cb..7f98a1f05b28fb15d45df727252e9b14461964f4 100644 (file)
@@ -156,6 +156,7 @@ class ConsumableDocument:
 
     source: DocumentSource
     original_file: Path
+    original_path: Path | None = None
     mailrule_id: int | None = None
     mime_type: str = dataclasses.field(init=False, default=None)
 
index 2088a60423f976fb34544e334d6a12822ac6b4cb..72f1af5cf37e9c3a55dc78c1cf7de017bbdd5d8e 100644 (file)
@@ -314,11 +314,19 @@ def consumable_document_matches_workflow(
         trigger_matched = False
 
     # Document path vs trigger path
+
+    # Use the original_path if set, else us the original_file
+    match_against = (
+        document.original_path
+        if document.original_path is not None
+        else document.original_file
+    )
+
     if (
         trigger.filter_path is not None
         and len(trigger.filter_path) > 0
         and not fnmatch(
-            document.original_file,
+            match_against,
             trigger.filter_path,
         )
     ):
index b2c28a82b0591c1901f91996d4347c7f5312c92b..0ad98344da66b5c00779ebf556bbb5f8eb0844eb 100644 (file)
@@ -614,14 +614,16 @@ class TestBarcodeNewConsume(
             self.assertIsNotFile(temp_copy)
 
             # Check the split files exist
+            # Check the original_path is set
             # Check the source is unchanged
             # Check the overrides are unchanged
             for (
                 new_input_doc,
                 new_doc_overrides,
             ) in self.get_all_consume_delay_call_args():
-                self.assertEqual(new_input_doc.source, DocumentSource.ConsumeFolder)
                 self.assertIsFile(new_input_doc.original_file)
+                self.assertEqual(new_input_doc.original_path, temp_copy)
+                self.assertEqual(new_input_doc.source, DocumentSource.ConsumeFolder)
                 self.assertEqual(overrides, new_doc_overrides)