A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Added system checks to warn people of misconfigurations
Daniel Quinn30be13ae33ed
diff --git a/src/documents/management/commands/document_consumer.py b/src/documents/management/commands/document_consumer.pyindex a03845bd3..366e75657 100644--- a/src/documents/management/commands/document_consumer.py+++ b/src/documents/management/commands/document_consumer.py@@ -19,7 +19,8 @@ class Command(BaseCommand):LOOP_TIME = 10 # SecondsMAIL_DELTA = datetime.timedelta(minutes=10)- MEDIA_DOCS = os.path.join(settings.MEDIA_ROOT, "documents")+ ORIGINAL_DOCS = os.path.join(settings.MEDIA_ROOT, "documents", "originals")+ THUMB_DOCS = os.path.join(settings.MEDIA_ROOT, "documents", "thumbnails")def __init__(self, *args, **kwargs):@@ -40,10 +41,11 @@ class Command(BaseCommand):except (ConsumerError, MailFetcherError) as e:raise CommandError(e)- try:- os.makedirs(self.MEDIA_DOCS)- except FileExistsError:- pass+ for path in (self.ORIGINAL_DOCS, self.THUMB_DOCS):+ try:+ os.makedirs(path)+ except FileExistsError:+ passlogging.getLogger(__name__).info("Starting document consumer at {}".format(settings.CONSUMPTION_DIR)diff --git a/src/paperless/__init__.py b/src/paperless/__init__.pyindex e69de29bb..c8c4b305b 100644--- a/src/paperless/__init__.py+++ b/src/paperless/__init__.py@@ -0,0 +1 @@+from .checks import paths_checkdiff --git a/src/paperless/checks.py b/src/paperless/checks.pynew file mode 100644index 000000000..a85d94e0b--- /dev/null+++ b/src/paperless/checks.py@@ -0,0 +1,47 @@+import os++from django.core.checks import Error, register, Warning+++@register()+def paths_check(app_configs, **kwargs):++ 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)+ ))++ return check_messages