From 5c4849796b25aa40b0c3c362bd3dfebcf98856cd Mon Sep 17 00:00:00 2001 From: Jonas Winkler Date: Thu, 29 Oct 2020 14:30:15 +0100 Subject: [PATCH] fixed folders, compatible with previous paperless version --- .gitignore | 5 ++-- Dockerfile | 1 + {data/media => media}/documents/.keep | 0 .../documents/originals}/.keep | 0 media/documents/thumbnails/.keep | 0 paperless.conf.example | 7 +++-- scripts/docker-entrypoint.sh | 28 +++++++++---------- src/documents/views.py | 1 - src/paperless/checks.py | 4 ++- src/paperless/settings.py | 6 ++-- 10 files changed, 28 insertions(+), 24 deletions(-) rename {data/media => media}/documents/.keep (100%) rename {data/media/thumbnails => media/documents/originals}/.keep (100%) create mode 100644 media/documents/thumbnails/.keep diff --git a/.gitignore b/.gitignore index 744ff3947..f19c0578b 100644 --- a/.gitignore +++ b/.gitignore @@ -76,8 +76,9 @@ scripts/nuke /static/ # Stored PDFs -/data/media/documents/* -/data/media/thumbnails/* +/media/documents/originals/* +/media/documents/thumbnails/* + /data/classification_model.pickle /data/db.sqlite3 /data/index diff --git a/Dockerfile b/Dockerfile index 4284b35ca..5fa6df7c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,6 +45,7 @@ RUN apt-get update \ unpaper \ && pip install --upgrade pipenv \ && pipenv install --system --deploy \ + && pipenv --clear \ && apt-get -y purge build-essential \ && apt-get -y autoremove --purge \ && rm -rf /var/lib/apt/lists/* diff --git a/data/media/documents/.keep b/media/documents/.keep similarity index 100% rename from data/media/documents/.keep rename to media/documents/.keep diff --git a/data/media/thumbnails/.keep b/media/documents/originals/.keep similarity index 100% rename from data/media/thumbnails/.keep rename to media/documents/originals/.keep diff --git a/media/documents/thumbnails/.keep b/media/documents/thumbnails/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/paperless.conf.example b/paperless.conf.example index ef1746cc7..2bb24cee4 100644 --- a/paperless.conf.example +++ b/paperless.conf.example @@ -25,10 +25,13 @@ # before you start Paperless. #PAPERLESS_CONSUMPTION_DIR="" -# This is where paperless stores all its data (documents, thumbnails, search -# index, sqlite database, etc). +# This is where paperless stores all its data (search index, sqlite database, +# classification model, etc). #PAPERLESS_DATA_DIR="../data" +# This is where your documents and thumbnails are stored. +#PAPERLESS_MEDIA_ROOT="../media" + # Override the default STATIC_ROOT here. This is where all static files # created using "collectstatic" manager command are stored. #PAPERLESS_STATICDIR="../static" diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index 3c9ec5c4a..9d4a429f4 100644 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -16,26 +16,25 @@ map_uidgid() { } migrations() { - # A simple lock file in case other containers use this startup - LOCKFILE="/usr/src/paperless/data/db.sqlite3.migration" - - # check for and create lock file in one command - if (set -o noclobber; echo "$$" > "${LOCKFILE}") 2> /dev/null - then - trap 'rm -f "${LOCKFILE}"; exit $?' INT TERM EXIT - sudo -HEu paperless python3 manage.py migrate - rm ${LOCKFILE} - fi + + ( + # flock is in place to prevent multiple containers from doing migrations + # simultaneously. This also ensures that the db is ready when the command + # of the current container starts. + flock 200 + sudo -HEu paperless python3 manage.py migrate + ) 200>/usr/src/paperless/data/migration_lock + } initialize() { map_uidgid - for data_dir in index media media/documents media/thumbnails; do - if [[ ! -d "../data/$data_dir" ]] + for dir in export data data/index media media/documents media/documents/originals media/documents/thumbnails; do + if [[ ! -d "../$dir" ]] then - echo "creating directory ../data/$data_dir" - mkdir ../data/$data_dir + echo "creating directory ../$dir" + mkdir ../$dir fi done @@ -46,7 +45,6 @@ initialize() { } install_languages() { - echo "TEST" local langs="$1" read -ra langs <<<"$langs" diff --git a/src/documents/views.py b/src/documents/views.py index 8f759f2a7..9bec12555 100755 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -95,7 +95,6 @@ class DocumentViewSet(RetrieveModelMixin, ordering_fields = ( "id", "title", "correspondent__name", "created", "modified", "added", "archive_serial_number") - def file_response(self, pk, disposition): #TODO: this should not be necessary here. content_types = { diff --git a/src/paperless/checks.py b/src/paperless/checks.py index bf584f3fb..0b725cfd6 100644 --- a/src/paperless/checks.py +++ b/src/paperless/checks.py @@ -33,7 +33,9 @@ def paths_check(app_configs, **kwargs): Check the various paths for existence, readability and writeability """ - check_messages = path_check("PAPERLESS_DATA_DIR") +\ + check_messages = path_check("PAPERLESS_DATA_DIR") + \ + path_check("PAPERLESS_MEDIA_ROOT") + \ + path_check("PAPERLESS_CONSUMPTION_DIR") + \ path_check("PAPERLESS_STATICDIR") return check_messages diff --git a/src/paperless/settings.py b/src/paperless/settings.py index a178fb6e1..9c5f2bd0f 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -39,11 +39,11 @@ def __get_boolean(key, default="NO"): DATA_DIR = os.getenv('PAPERLESS_DATA_DIR', os.path.join(BASE_DIR, "..", "data")) -MEDIA_ROOT = os.path.join(DATA_DIR, "media") +MEDIA_ROOT = os.getenv('PAPERLESS_MEDIA_ROOT', os.path.join(BASE_DIR, "..", "media")) INDEX_DIR = os.path.join(DATA_DIR, "index") -ORIGINALS_DIR = os.path.join(MEDIA_ROOT, "documents") -THUMBNAIL_DIR = os.path.join(MEDIA_ROOT, "thumbnails") +ORIGINALS_DIR = os.path.join(MEDIA_ROOT, "documents", "originals") +THUMBNAIL_DIR = os.path.join(MEDIA_ROOT, "documents", "thumbnails") MODEL_FILE = os.path.join(DATA_DIR, "classification_model.pickle") # Quick-start development settings - unsuitable for production