mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-12 01:26:47 +01:00
added sanity checker management command for manual execution #534
This commit is contained in:
parent
ed478a1d73
commit
8b2965d55b
6 changed files with 101 additions and 3 deletions
27
src/documents/management/commands/document_sanity_checker.py
Normal file
27
src/documents/management/commands/document_sanity_checker.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import logging
|
||||
from django.core.management.base import BaseCommand
|
||||
from documents.sanity_checker import check_sanity, SanityError, SanityWarning
|
||||
|
||||
logger = logging.getLogger("paperless.management.sanity_checker")
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
help = """
|
||||
This command checks your document archive for issues.
|
||||
""".replace(" ", "")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
||||
messages = check_sanity(progress=True)
|
||||
|
||||
if len(messages) == 0:
|
||||
logger.info("No issues found.")
|
||||
else:
|
||||
for msg in messages:
|
||||
if type(msg) == SanityError:
|
||||
logger.error(str(msg))
|
||||
elif type(msg) == SanityWarning:
|
||||
logger.warning(str(msg))
|
||||
else:
|
||||
logger.info((str(msg)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue