paperless-ngx/src/documents/management/commands/document_index.py

20 lines
562 B
Python
Raw Normal View History

from django.core.management import BaseCommand
2020-12-22 13:04:22 +01:00
from django.db import transaction
from documents.tasks import index_reindex, index_optimize
2021-02-04 23:40:53 +01:00
class Command(BaseCommand):
2020-10-27 17:08:18 +01:00
help = "Manages the document index."
2020-10-27 17:08:18 +01:00
def add_arguments(self, parser):
parser.add_argument("command", choices=['reindex', 'optimize'])
def handle(self, *args, **options):
2020-12-22 13:04:22 +01:00
with transaction.atomic():
if options['command'] == 'reindex':
index_reindex()
elif options['command'] == 'optimize':
index_optimize()