mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-05-24 07:25:26 +00:00
e30676f889
* Refactor: migrate exporter/importer from tqdm to PaperlessCommand.track() Replace direct tqdm usage in document_exporter and document_importer with the PaperlessCommand base class and its track() method, which is backed by Rich and handles --no-progress-bar automatically. Also removes the unused ProgressBarMixin from mixins.py. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Refactor: add explicit supports_progress_bar and supports_multiprocessing to all PaperlessCommand subclasses Each management command now explicitly declares both class attributes rather than relying on defaults, making intent unambiguous at a glance. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
29 lines
908 B
Python
29 lines
908 B
Python
from django.db import transaction
|
|
|
|
from documents.management.commands.base import PaperlessCommand
|
|
from documents.tasks import index_optimize
|
|
from documents.tasks import index_reindex
|
|
|
|
|
|
class Command(PaperlessCommand):
|
|
help = "Manages the document index."
|
|
|
|
supports_progress_bar = True
|
|
supports_multiprocessing = False
|
|
|
|
def add_arguments(self, parser):
|
|
super().add_arguments(parser)
|
|
parser.add_argument("command", choices=["reindex", "optimize"])
|
|
|
|
def handle(self, *args, **options):
|
|
with transaction.atomic():
|
|
if options["command"] == "reindex":
|
|
index_reindex(
|
|
iter_wrapper=lambda docs: self.track(
|
|
docs,
|
|
description="Indexing documents...",
|
|
),
|
|
)
|
|
elif options["command"] == "optimize":
|
|
index_optimize()
|