From c26962f17f9b893d02f0ae0779c55f0510194032 Mon Sep 17 00:00:00 2001 From: Jonas Winkler Date: Tue, 27 Oct 2020 17:08:18 +0100 Subject: [PATCH] changed a few things --- paperless.conf.example | 44 +++---------------- .../management/commands/document_index.py | 19 +++++--- src/paperless/settings.py | 8 ++-- 3 files changed, 22 insertions(+), 49 deletions(-) diff --git a/paperless.conf.example b/paperless.conf.example index b46f8d7e0..55939f858 100644 --- a/paperless.conf.example +++ b/paperless.conf.example @@ -21,44 +21,22 @@ # This where your documents should go to be consumed. Make sure that it exists # and that the user running the paperless service can read/write its contents # before you start Paperless. -PAPERLESS_CONSUMPTION_DIR="" - - -# You can specify where you want the SQLite database to be stored instead of -# the default location of /data/ within the install directory. -#PAPERLESS_DBDIR=/path/to/database/file - - -# Override the default MEDIA_ROOT here. This is where all files are stored. -# The default location is /media/documents/ within the install folder. -#PAPERLESS_MEDIADIR=/path/to/media +#PAPERLESS_CONSUMPTION_DIR="" +# This is where paperless stores all its data (documents, thumbnails, search +# index, sqlite database, etc). +#PAPERLESS_DATA_DIR="../data" # Override the default STATIC_ROOT here. This is where all static files # created using "collectstatic" manager command are stored. #PAPERLESS_STATICDIR="" -# This is where the whoosh document index is stored -#PAPERLESS_INDEX_DIR="/path/to/index" - - -# Override the MEDIA_URL here. Unless you're hosting Paperless off a subdomain -# like /paperless/, you probably don't need to change this. -#PAPERLESS_MEDIA_URL="/media/" - # Override the STATIC_URL here. Unless you're hosting Paperless off a # subdomain like /paperless/, you probably don't need to change this. #PAPERLESS_STATIC_URL="/static/" -# You can specify where the document classification model file should be -# stored. Make sure that this file is writeable by the user executing the -# management command "document_create_classifier" and that the path exists. -# The default location is /models/model.pickle wwithin the install folder. -#PAPERLESS_MODEL_FILE=/path/to/model/file - - # These values are required if you want paperless to check a particular email # box every 10 minutes and attempt to consume documents from there. If you # don't define a HOST, mail checking will just be disabled. @@ -75,25 +53,13 @@ PAPERLESS_CONSUME_MAIL_PASS="" # ignored. PAPERLESS_EMAIL_SECRET="" -# Specify a filename format for the document (directories are supported) -# Use the following placeholders: -# * {correspondent} -# * {title} -# * {created} -# * {added} -# * {tags[KEY]} If your tags conform to key_value or key-value -# * {tags[INDEX]} If your tags are strings, select the tag by index -# Uniqueness of filenames is ensured, as an incrementing counter is attached -# to each filename. -#PAPERLESS_FILENAME_FORMAT="" - ############################################################################### #### Security #### ############################################################################### # Controls whether django's debug mode is enabled. Disable this on production # systems. Debug mode is enabled by default. -#PAPERLESS_DEBUG="true" +#PAPERLESS_DEBUG="false" # Paperless can be instructed to attempt to encrypt your PDF files with GPG diff --git a/src/documents/management/commands/document_index.py b/src/documents/management/commands/document_index.py index a5fd892a9..5a136d6a5 100644 --- a/src/documents/management/commands/document_index.py +++ b/src/documents/management/commands/document_index.py @@ -8,20 +8,27 @@ from documents.models import Document class Command(Renderable, BaseCommand): - help = "Recreates the document index" + help = "Manages the document index." def __init__(self, *args, **kwargs): self.verbosity = 0 BaseCommand.__init__(self, *args, **kwargs) + def add_arguments(self, parser): + parser.add_argument("command", choices=['reindex', 'optimize']) + def handle(self, *args, **options): self.verbosity = options["verbosity"] - documents = Document.objects.all() + if options['command'] == 'reindex': + documents = Document.objects.all() - ix = index.open_index(recreate=True) + ix = index.open_index(recreate=True) - with AsyncWriter(ix) as writer: - for document in documents: - index.update_document(writer, document) + with AsyncWriter(ix) as writer: + for document in documents: + index.update_document(writer, document) + + elif options['command'] == 'optimize': + index.open_index().optimize() diff --git a/src/paperless/settings.py b/src/paperless/settings.py index 4771bfc3c..ad1f73ed6 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -39,7 +39,7 @@ 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")) -MEDIA_ROOT = os.getenv('PAPERLESS_DATA_DIR', os.path.join(DATA_DIR, "media")) +MEDIA_ROOT = os.path.join(DATA_DIR, "media") INDEX_DIR = os.path.join(DATA_DIR, "index") ORIGINALS_DIR = os.path.join(MEDIA_ROOT, "documents") @@ -59,15 +59,15 @@ SECRET_KEY = os.getenv( # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = __get_boolean("PAPERLESS_DEBUG", "YES") +DEBUG = __get_boolean("PAPERLESS_DEBUG", "NO") LOGIN_URL = "admin:login" -ALLOWED_HOSTS = ["*"] - _allowed_hosts = os.getenv("PAPERLESS_ALLOWED_HOSTS") if _allowed_hosts: ALLOWED_HOSTS = _allowed_hosts.split(",") +else: + ALLOWED_HOSTS = ["*"] FORCE_SCRIPT_NAME = os.getenv("PAPERLESS_FORCE_SCRIPT_NAME")