Skip to content

Commit

Permalink
Merge pull request #12 from cschneider83/patch-1
Browse files Browse the repository at this point in the history
Use Source Path instead of Archive Path if Archive Path is "None"
  • Loading branch information
marcelbrueckner authored Jan 20, 2025
2 parents c40617d + 2dd6496 commit a5d8df1
Showing 1 changed file with 10 additions and 2 deletions.
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

0 comments on commit a5d8df1

Please sign in to comment.