Skip to content

Conversation

DerRockWolf
Copy link

@DerRockWolf DerRockWolf commented Aug 30, 2025

Proposed change

Closes #10709

This change introduces a new optional field in the ConsumableDocument class: original_path. It can be used to add the actual original document path for later use. In this change the original_path is used for matching the document path in workflows.

Previously documents split by barcode wouldn't match workflows that were using a filter path in the trigger.
Now, if a ConsumableDocument has original_path set, the workflow match logic will use it instead of the path where the document is currently (at the time of matching) located. The current path, for split documents, is a temporary directory without the sub directories of the consume folder.

I've also renamed the original_file field of ConsumableDocument to path as it more clearly communicates what this field is used to. If you don't like it, feel free to just drop the commit.

This can be tested with any workflow that assigns metadata to consumed documents based on the consumption path:

  1. Create a sub directory (test) in the consume directory
  2. Create a workflow with trigger filter path: */test/*
  3. Copy the PDF to /consume/test/

Previously these workflow triggers didn't match for PDFs with PATCHT barcodes as the split PDFs are copied to a temporary directory and therefore didn't retain any information about the original consumption path.

Type of change

  • Bug fix: non-breaking change which fixes an issue.
  • New feature / Enhancement: non-breaking change which adds functionality. Please read the important note above.
  • Breaking change: fix or feature that would cause existing functionality to not work as expected.
  • Documentation only.
  • Other. Please explain:

Checklist:

  • I have read & agree with the contributing guidelines.
  • If applicable, I have included testing coverage for new code in this PR, for backend and / or front-end changes.
  • If applicable, I have tested my code for new features & regressions on both mobile & desktop devices, using the latest version of major browsers.
  • If applicable, I have checked that all tests pass, see documentation.
  • I have run all pre-commit hooks, see documentation.
  • I have made corresponding changes to the documentation as needed.
  • I have checked my modifications for any breaking changes.

@DerRockWolf DerRockWolf requested a review from a team as a code owner August 30, 2025 17:58
@github-actions github-actions bot added backend non-trivial Requires approval by several team members enhancement New feature or enhancement labels Aug 30, 2025
Copy link
Contributor

Hello @DerRockWolf,

Thank you very much for submitting this PR to us!

This is what will happen next:

  1. CI tests will run against your PR to ensure quality and consistency.
  2. Next, human contributors from paperless-ngx review your changes.
  3. Please address any issues that come up during the review as soon as you are able to.
  4. If accepted, your pull request will be merged into the dev branch and changes there will be tested further.
  5. Eventually, changes from you and other contributors will be merged into main and a new release will be made.

You'll be hearing from us soon, and thank you again for contributing to our project.

@shamoon shamoon changed the title feat: workflow document path matching of barcode splitted documents using original consumption path Enhancement: workflow document path matching of barcode splitted documents using original consumption path Aug 30, 2025
@shamoon shamoon changed the title Enhancement: workflow document path matching of barcode splitted documents using original consumption path Enhancement: support workflow path matching of barcode-split documents Aug 30, 2025
Copy link
Member

@shamoon shamoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, please drop the rename commit

@DerRockWolf DerRockWolf force-pushed the feat/workflow-matching-splitting branch from 593c5b9 to bdcfa8d Compare August 30, 2025 19:21
@DerRockWolf
Copy link
Author

Yea, please drop the rename commit

done ✅

@DerRockWolf DerRockWolf requested a review from shamoon August 30, 2025 19:43
@DerRockWolf DerRockWolf force-pushed the feat/workflow-matching-splitting branch from bdcfa8d to 17dbb20 Compare August 31, 2025 07:59
@DerRockWolf
Copy link
Author

Formatting is now also fixed. It was included in the dropped commit 😅

Copy link
Member

@shamoon shamoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM but I'll hold off on merging until our main backend dev has a chance to take a look.

@shamoon
Copy link
Member

shamoon commented Sep 11, 2025

(does need a rebase)

auto-merge was automatically disabled September 11, 2025 19:50

Head branch was pushed to by a user without write access

@DerRockWolf DerRockWolf force-pushed the feat/workflow-matching-splitting branch from 17dbb20 to 973d4b9 Compare September 11, 2025 19:50
@DerRockWolf
Copy link
Author

Thanks for your time 🙂 Rebase is also done.

What I have now also noticed, is that this doesn't solve it for people using PAPERLESS_CONSUMER_SUBDIRS_AS_TAGS as this happens in the _consume function in documents/management/commands/document_consumer.py and the tags added there won't be retained by the barcode logic.

I'm not yet 100% sure how the solution could look like, but I'm going to further hack around and will open another PR for the "subdirs as tags" case.
Are there any other locations where barcode splitting causes metadata to get lost?

@DerRockWolf DerRockWolf force-pushed the feat/workflow-matching-splitting branch from 6bdd576 to 06851e9 Compare September 11, 2025 20:22
@shamoon shamoon enabled auto-merge (squash) September 11, 2025 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend enhancement New feature or enhancement non-trivial Requires approval by several team members
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants