A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
run the polling file change checks on individual threads to speed up queueing of new files
jonaswinklerbac4a63cc81c
diff --git a/src/documents/management/commands/document_consumer.py b/src/documents/management/commands/document_consumer.pyindex b2549efbf..969941af9 100644--- a/src/documents/management/commands/document_consumer.py+++ b/src/documents/management/commands/document_consumer.py@@ -1,6 +1,7 @@import loggingimport osfrom pathlib import Path+from threading import Threadfrom time import sleepfrom django.conf import settings@@ -57,6 +58,7 @@ def _consume(filepath):logger.exception("Error creating tags from path")try:+ logger.info(f"Adding {filepath} to the task queue.")async_task("documents.tasks.consume_file",filepath,override_tag_ids=tag_ids if tag_ids else None,@@ -69,6 +71,7 @@ def _consume(filepath):def _consume_wait_unmodified(file):+ logger.debug(f"Waiting for file {file} to remain unmodified")mtime = -1current_try = 0while current_try < settings.CONSUMER_POLLING_RETRY_COUNT:@@ -91,10 +94,14 @@ def _consume_wait_unmodified(file):class Handler(FileSystemEventHandler):def on_created(self, event):- _consume_wait_unmodified(event.src_path)+ Thread(+ target=_consume_wait_unmodified, args=(event.src_path,)+ ).start()def on_moved(self, event):- _consume_wait_unmodified(event.dest_path)+ Thread(+ target=_consume_wait_unmodified, args=(event.dest_path,)+ ).start()class Command(BaseCommand):diff --git a/src/paperless/settings.py b/src/paperless/settings.pyindex b0ce32305..bf9fcd459 100644--- a/src/paperless/settings.py+++ b/src/paperless/settings.py@@ -428,7 +428,7 @@ CONSUMER_POLLING = int(os.getenv("PAPERLESS_CONSUMER_POLLING", 0))CONSUMER_POLLING_DELAY = int(os.getenv("PAPERLESS_CONSUMER_POLLING_DELAY", 5))CONSUMER_POLLING_RETRY_COUNT = int(- os.getenv("PAPERLESS_CONSUMER_POLLING_RETRY_COUNT", 30 / CONSUMER_POLLING_DELAY)+ os.getenv("PAPERLESS_CONSUMER_POLLING_RETRY_COUNT", 5))CONSUMER_DELETE_DUPLICATES = __get_boolean("PAPERLESS_CONSUMER_DELETE_DUPLICATES")