mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-15 10:13:15 -05:00
Added system checks to warn people of misconfigurations
This commit is contained in:
parent
8fc3d8a27e
commit
30be13ae33
@ -19,7 +19,8 @@ class Command(BaseCommand):
|
|||||||
LOOP_TIME = 10 # Seconds
|
LOOP_TIME = 10 # Seconds
|
||||||
MAIL_DELTA = datetime.timedelta(minutes=10)
|
MAIL_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):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
@ -40,10 +41,11 @@ class Command(BaseCommand):
|
|||||||
except (ConsumerError, MailFetcherError) as e:
|
except (ConsumerError, MailFetcherError) as e:
|
||||||
raise CommandError(e)
|
raise CommandError(e)
|
||||||
|
|
||||||
try:
|
for path in (self.ORIGINAL_DOCS, self.THUMB_DOCS):
|
||||||
os.makedirs(self.MEDIA_DOCS)
|
try:
|
||||||
except FileExistsError:
|
os.makedirs(path)
|
||||||
pass
|
except FileExistsError:
|
||||||
|
pass
|
||||||
|
|
||||||
logging.getLogger(__name__).info(
|
logging.getLogger(__name__).info(
|
||||||
"Starting document consumer at {}".format(settings.CONSUMPTION_DIR)
|
"Starting document consumer at {}".format(settings.CONSUMPTION_DIR)
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
from .checks import paths_check
|
47
src/paperless/checks.py
Normal file
47
src/paperless/checks.py
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user