diff --git a/paperless/data/consume/.gitkeep b/paperless/data/consume/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/paperless/data/export/.gitkeep b/paperless/data/export/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/paperless/docker-compose.yml b/paperless/docker-compose.yml index 241d0dc18..49e99e4ef 100644 --- a/paperless/docker-compose.yml +++ b/paperless/docker-compose.yml @@ -34,10 +34,10 @@ services: volumes: - ${APP_DATA_DIR}/data/data:/usr/src/paperless/data - ${APP_DATA_DIR}/data/media:/usr/src/paperless/media - # TODO(#1466): default these to Paperless app data once users can remap app - # folders to shared storage, preserving network-share workflows. - - ${UMBREL_ROOT}/data/storage/paperless/export:/usr/src/paperless/export - - ${UMBREL_ROOT}/data/storage/paperless/consume:/usr/src/paperless/consume + # Defaults for the consume and export folder settings in umbrel-app.yml. + # Users can point them at Home, external drives or network shares. + - ${APP_DATA_DIR}/data/export:/usr/src/paperless/export + - ${APP_DATA_DIR}/data/consume:/usr/src/paperless/consume environment: PAPERLESS_REDIS: redis://paperless_broker_1:6379 PAPERLESS_DBHOST: paperless_db_1 diff --git a/paperless/exports.sh b/paperless/exports.sh index 58f9e5672..895885ae3 100644 --- a/paperless/exports.sh +++ b/paperless/exports.sh @@ -1,32 +1,2 @@ -# Ensure that Paperless consume and export directories are created with the correct permissions -UMBREL_DATA_DIR="${UMBREL_ROOT}/data" -UMBREL_DATA_STORAGE_DIR="${UMBREL_DATA_DIR}/storage" -UMBREL_DATA_STORAGE_PAPERLESS_DIR="${UMBREL_DATA_STORAGE_DIR}/paperless" -UMBREL_DATA_STORAGE_PAPERLESS_CONSUME_DIR="${UMBREL_DATA_STORAGE_PAPERLESS_DIR}/consume" -UMBREL_DATA_STORAGE_PAPERLESS_EXPORT_DIR="${UMBREL_DATA_STORAGE_PAPERLESS_DIR}/export" -DESIRED_OWNER="1000:1000" - -if [[ ! -d "${UMBREL_DATA_STORAGE_PAPERLESS_CONSUME_DIR}" ]]; then - mkdir -p "${UMBREL_DATA_STORAGE_PAPERLESS_CONSUME_DIR}" -fi - -if [[ ! -d "${UMBREL_DATA_STORAGE_PAPERLESS_EXPORT_DIR}" ]]; then - mkdir -p "${UMBREL_DATA_STORAGE_PAPERLESS_EXPORT_DIR}" -fi - -set_paperless_correct_permissions() { - local -r path="${1}" - - if [[ -d "${path}" ]]; then - owner=$(stat -c "%u:%g" "${path}") - - if [[ "${owner}" != "${DESIRED_OWNER}" ]]; then - chown "${DESIRED_OWNER}" "${path}" - fi - fi -} - -set_paperless_correct_permissions "${UMBREL_DATA_STORAGE_DIR}" -set_paperless_correct_permissions "${UMBREL_DATA_STORAGE_PAPERLESS_DIR}" -set_paperless_correct_permissions "${UMBREL_DATA_STORAGE_PAPERLESS_CONSUME_DIR}" -set_paperless_correct_permissions "${UMBREL_DATA_STORAGE_PAPERLESS_EXPORT_DIR}" +# Paperless's consume and export folders live in app data since 3.4.2-patch.2. +# Kept empty so updates replace the old copy that created folders in Home. diff --git a/paperless/hooks/pre-start b/paperless/hooks/pre-start index a30ebcea2..bb18b15c6 100755 --- a/paperless/hooks/pre-start +++ b/paperless/hooks/pre-start @@ -1,8 +1,30 @@ #!/usr/bin/env bash set -euo pipefail -# Paperless 3.0.2 and later restore the released paperless_mail.0002 migration -# graph, so the temporary 3.0.1 migration-history backfill must not run for -# users who skip directly from that package. Keep this no-op hook so updates -# overwrite the old copied hook in existing app data. -echo "paperless pre-start: upstream 3.0.2+ migration fix active; no migration-history backfill needed" +APP_DIR="${APP_DATA_DIR:-$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/..")}" +DATA_ROOT="${APP_DATA_ROOT:-${APP_DIR}/data}" +CONSUME_DIR="${DATA_ROOT}/consume" +EXPORT_DIR="${DATA_ROOT}/export" +# Package-local so moving app data never reruns the migration. +MIGRATION_MARKER="${APP_DIR}/.consume-moved-to-app-data" + +# Paperless runs as uid/gid 1000. +mkdir -p "${CONSUME_DIR}" "${EXPORT_DIR}" +chown 1000:1000 "${CONSUME_DIR}" "${EXPORT_DIR}" + +if [[ -f "${MIGRATION_MARKER}" ]]; then + exit 0 +fi + +# Before 3.4.2-patch.2 the consume folder lived in Home (or the older +# data/storage path). Move documents still waiting there so Paperless +# imports them. Earlier exports stay in Home/paperless/export untouched. +for legacy_consume_dir in "${UMBREL_ROOT}/home/paperless/consume" "${UMBREL_ROOT}/data/storage/paperless/consume"; do + if [[ -d "${legacy_consume_dir}" ]]; then + echo "paperless pre-start: moving pending documents from ${legacy_consume_dir}" + find "${legacy_consume_dir}" -mindepth 1 -maxdepth 1 -exec mv -n -t "${CONSUME_DIR}" {} + + fi +done +chown -R 1000:1000 "${CONSUME_DIR}" + +touch "${MIGRATION_MARKER}" diff --git a/paperless/umbrel-app.yml b/paperless/umbrel-app.yml index f8f1b1c04..c6e70effc 100644 --- a/paperless/umbrel-app.yml +++ b/paperless/umbrel-app.yml @@ -1,14 +1,36 @@ manifestVersion: 1.1 id: paperless +storage: + dataRoot: data +folderAccess: + - id: consume + name: Consume + note: >- + Drop files in this folder and Paperless-ngx adds them to your documents. By default it's inside the app's own storage. To add files from a scanner or another device, choose a folder in Home, on a drive or on a network share. + mounts: + - service: webserver + targetPath: /usr/src/paperless/consume + - id: export + name: Export + note: >- + Where Paperless-ngx saves a full copy of your documents when you run its document exporter. By default it's inside the app's own storage. Choose a folder in Home, on a drive or on a network share to open exports from another device. + mounts: + - service: webserver + targetPath: /usr/src/paperless/export environment: - name: PAPERLESS_OCR_LANGUAGES services: - webserver note: >- - Extra OCR languages to install, separated by spaces, such as ces tur chi-sim. English, German, French, Italian and Spanish are included. They download each time Paperless starts. Keep a language here while Paperless's OCR language setting uses it. + Extra languages Paperless-ngx can read in your documents, separated by spaces, for example: ces tur chi-sim. English, German, French, Italian and Spanish are already included. Extra languages download each time the app starts. Keep a language here while Paperless-ngx's OCR settings use it. + - name: PAPERLESS_CONSUMER_POLLING + services: + - webserver + note: >- + Only needed if the Consume folder is on a network share, because Paperless-ngx can't notice new files there on its own. Enter how often to check for new files, in seconds, for example 60. Leave empty otherwise. category: files name: Paperless-ngx -version: "3.4.2-patch.1" +version: "3.4.2-patch.2" tagline: Transform your physical documents into a searchable online archive description: >- Paperless-ngx is a community-supported open-source document management system that transforms your physical documents into a searchable online archive so you can keep, well, less paper. @@ -25,11 +47,20 @@ description: >- - Uses machine-learning to automatically add tags, correspondents and document types to your documents. - - Supports PDF documents, images, plain text files, Office documents (Word, Excel, Powerpoint, and LibreOffice equivalents)1 and more. + - Supports PDF documents, images, plain text files, Office documents (Word, Excel, PowerPoint, and LibreOffice equivalents) and more. - Paperless stores your documents plain on disk. Filenames and folders are managed by paperless and their format can be configured freely with different configurations assigned to different documents. releaseNotes: >- - This update lets you install extra OCR languages in Paperless-ngx's app settings on umbrelOS 2.0. + This update adds support for new storage management and configuration options introduced with umbrelOS 2.0. + + + Paperless-ngx's consume and export folders have moved into the app's own storage, so they're now included in your backups. Any files still waiting in Home/paperless/consume are moved across and imported. Your earlier exports stay in Home/paperless/export. + + + If a scanner or another device saves files to Home/paperless/consume, open Paperless-ngx's app settings and choose that folder as the Consume folder so it keeps working. You can also choose a folder on a drive or a network share. + + + The previous update added extra OCR languages to Paperless-ngx's app settings. Previous Paperless-ngx 3.4.2 release notes: