mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
unified data folders
This commit is contained in:
@@ -4,6 +4,28 @@ import shutil
|
||||
from django.conf import settings
|
||||
from django.core.checks import Error, Warning, register
|
||||
|
||||
exists_message = "{} is set but doesn't exist."
|
||||
exists_hint = "Create a directory at {}"
|
||||
writeable_message = "{} is not writeable"
|
||||
writeable_hint = (
|
||||
"Set the permissions of {} to be writeable by the user running the "
|
||||
"Paperless services"
|
||||
)
|
||||
def path_check(env_var):
|
||||
messages = []
|
||||
directory = os.getenv(env_var)
|
||||
if directory:
|
||||
if not os.path.exists(directory):
|
||||
messages.append(Error(
|
||||
exists_message.format(env_var),
|
||||
exists_hint.format(directory)
|
||||
))
|
||||
elif not os.access(directory, os.W_OK | os.X_OK):
|
||||
messages.append(Error(
|
||||
writeable_message.format(env_var),
|
||||
writeable_hint.format(directory)
|
||||
))
|
||||
return messages
|
||||
|
||||
@register()
|
||||
def paths_check(app_configs, **kwargs):
|
||||
@@ -11,57 +33,8 @@ def paths_check(app_configs, **kwargs):
|
||||
Check the various paths for existence, readability and writeability
|
||||
"""
|
||||
|
||||
check_messages = []
|
||||
|
||||
exists_message = "{} is set but doesn't exist."
|
||||
exists_hint = "Create a directory at {}"
|
||||
writeable_message = "{} is not writeable"
|
||||
writeable_hint = (
|
||||
"Set the permissions of {} to be writeable by the user running the "
|
||||
"Paperless services"
|
||||
)
|
||||
|
||||
directory = os.getenv("PAPERLESS_DBDIR")
|
||||
if directory:
|
||||
if not os.path.exists(directory):
|
||||
check_messages.append(Error(
|
||||
exists_message.format("PAPERLESS_DBDIR"),
|
||||
exists_hint.format(directory)
|
||||
))
|
||||
if not check_messages:
|
||||
if not os.access(directory, os.W_OK | os.X_OK):
|
||||
check_messages.append(Error(
|
||||
writeable_message.format("PAPERLESS_DBDIR"),
|
||||
writeable_hint.format(directory)
|
||||
))
|
||||
|
||||
directory = os.getenv("PAPERLESS_MEDIADIR")
|
||||
if directory:
|
||||
if not os.path.exists(directory):
|
||||
check_messages.append(Error(
|
||||
exists_message.format("PAPERLESS_MEDIADIR"),
|
||||
exists_hint.format(directory)
|
||||
))
|
||||
if not check_messages:
|
||||
if not os.access(directory, os.W_OK | os.X_OK):
|
||||
check_messages.append(Error(
|
||||
writeable_message.format("PAPERLESS_MEDIADIR"),
|
||||
writeable_hint.format(directory)
|
||||
))
|
||||
|
||||
directory = os.getenv("PAPERLESS_STATICDIR")
|
||||
if directory:
|
||||
if not os.path.exists(directory):
|
||||
check_messages.append(Error(
|
||||
exists_message.format("PAPERLESS_STATICDIR"),
|
||||
exists_hint.format(directory)
|
||||
))
|
||||
if not check_messages:
|
||||
if not os.access(directory, os.W_OK | os.X_OK):
|
||||
check_messages.append(Error(
|
||||
writeable_message.format("PAPERLESS_STATICDIR"),
|
||||
writeable_hint.format(directory)
|
||||
))
|
||||
check_messages = path_check("PAPERLESS_DATA_DIR") +\
|
||||
path_check("PAPERLESS_STATICDIR")
|
||||
|
||||
return check_messages
|
||||
|
||||
|
@@ -37,6 +37,12 @@ def __get_boolean(key, default="NO"):
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
DATA_DIR = os.getenv('PAPERLESS_DATA_DIR', os.path.join(BASE_DIR, "..", "data"))
|
||||
|
||||
INDEX_DIR = os.path.join(DATA_DIR, "index")
|
||||
ORIGINALS_DIR = os.path.join(DATA_DIR, "documents")
|
||||
THUMBNAIL_DIR = os.path.join(DATA_DIR, "thumbnails")
|
||||
MODEL_FILE = os.path.join(DATA_DIR, "classification_model.pickle")
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
|
||||
@@ -145,10 +151,7 @@ DATABASES = {
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.sqlite3",
|
||||
"NAME": os.path.join(
|
||||
os.getenv(
|
||||
"PAPERLESS_DBDIR",
|
||||
os.path.join(BASE_DIR, "..", "data")
|
||||
),
|
||||
DATA_DIR,
|
||||
"db.sqlite3"
|
||||
)
|
||||
}
|
||||
@@ -206,11 +209,8 @@ USE_TZ = True
|
||||
|
||||
STATIC_ROOT = os.getenv(
|
||||
"PAPERLESS_STATICDIR", os.path.join(BASE_DIR, "..", "static"))
|
||||
MEDIA_ROOT = os.getenv(
|
||||
"PAPERLESS_MEDIADIR", os.path.join(BASE_DIR, "..", "media"))
|
||||
|
||||
STATIC_URL = os.getenv("PAPERLESS_STATIC_URL", "/static/")
|
||||
MEDIA_URL = os.getenv("PAPERLESS_MEDIA_URL", "/media/")
|
||||
|
||||
|
||||
# Other
|
||||
@@ -223,14 +223,6 @@ MEDIA_URL = os.getenv("PAPERLESS_MEDIA_URL", "/media/")
|
||||
DATA_UPLOAD_MAX_NUMBER_FIELDS = None
|
||||
|
||||
|
||||
# Document classification models location
|
||||
MODEL_FILE = os.getenv(
|
||||
"PAPERLESS_MODEL_FILE", os.path.join(
|
||||
BASE_DIR, "..", "models", "model.pickle"
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# Paperless-specific stuff
|
||||
# You shouldn't have to edit any of these values. Rather, you can set these
|
||||
# values in /etc/paperless.conf instead.
|
||||
@@ -294,7 +286,6 @@ SCRATCH_DIR = os.getenv("PAPERLESS_SCRATCH_DIR", "/tmp/paperless")
|
||||
# This is where Paperless will look for PDFs to index
|
||||
CONSUMPTION_DIR = os.getenv("PAPERLESS_CONSUMPTION_DIR")
|
||||
|
||||
INDEX_DIR = os.getenv('PAPERLESS_INDEX_DIR', os.path.join(BASE_DIR, "..", "index"))
|
||||
|
||||
# (This setting is ignored on Linux where inotify is used instead of a
|
||||
# polling loop.)
|
||||
|
@@ -1,5 +1,4 @@
|
||||
from django.conf import settings
|
||||
from django.conf.urls import include, static, url
|
||||
from django.conf.urls import include, url
|
||||
from django.contrib import admin
|
||||
from rest_framework.authtoken import views
|
||||
from rest_framework.routers import DefaultRouter
|
||||
@@ -39,7 +38,7 @@ urlpatterns = [
|
||||
# Root of the Frontent
|
||||
url(r".*", IndexView.as_view()),
|
||||
|
||||
] + static.static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
]
|
||||
|
||||
# Text in each page's <h1> (and above login form).
|
||||
admin.site.site_header = 'Paperless'
|
||||
|
Reference in New Issue
Block a user