Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Source Path instead of Archive Path if Archive Path is "None" #12

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
# Make sure organize-tool and poppler-utils has been installed
# on your system (resp. container, via custom-cont-init.d)

# In certain cases, like encrypted PDFs, no archived version is created by paperless.
# In this case, the archive path is "None". However, organize can still use the file.
# Therefore, use the source path instead.
if [[ "${DOCUMENT_ARCHIVE_PATH}" != "None" ]] ;then
DOCUMENT="${DOCUMENT_ARCHIVE_PATH}"
else
DOCUMENT="${DOCUMENT_SOURCE_PATH}"
fi
# organize-tool doesn't accept full file path as argument
# but expects directory and filename pattern without extension instead
export DOCUMENT_ARCHIVE_FILENAME=$(basename "${DOCUMENT_ARCHIVE_PATH}")
export DOCUMENT_ARCHIVE_DIR=$(dirname "${DOCUMENT_ARCHIVE_PATH}")
export DOCUMENT_ARCHIVE_FILENAME=$(basename "${DOCUMENT}")
export DOCUMENT_ARCHIVE_DIR=$(dirname "${DOCUMENT}")

# While organize supports environment variables as placeholders in it's configuration,
# it's not yet supported everywhere in the configuration (e.g. filters),
Expand Down