mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Added system checks to warn people of misconfigurations
This commit is contained in:
@@ -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
|
Reference in New Issue
Block a user