A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
increased default delay when waiting for file changes with polling
jonaswinkler0453787d3822
diff --git a/docs/changelog.rst b/docs/changelog.rstindex 721997323..f5a353adb 100644--- a/docs/changelog.rst+++ b/docs/changelog.rst@@ -21,14 +21,11 @@ paperless-ng 1.2.0* Improved responsiveness when switching between saved views and the document list.-* Paperless no longer depends on ``libpoppler-cpp-dev``.--paperless-ng 1.1.4-##################+* Increased the default wait time when observing files in the consumption folder+ with polling from 1 to 5 seconds. This will decrease the likelihood of paperless+ consuming partially written files.-* Added English (GB) locale.--* Added ISO-8601 date display option.+* Paperless no longer depends on ``libpoppler-cpp-dev``... note::@@ -41,6 +38,13 @@ paperless-ng 1.1.4If using docker, this does not affect you.+paperless-ng 1.1.4+##################++* Added English (GB) locale.++* Added ISO-8601 date display option.+paperless-ng 1.1.3##################diff --git a/src/documents/management/commands/document_consumer.py b/src/documents/management/commands/document_consumer.pyindex aaa644891..b2549efbf 100644--- a/src/documents/management/commands/document_consumer.py+++ b/src/documents/management/commands/document_consumer.py@@ -68,10 +68,10 @@ def _consume(filepath):logger.exception("Error while consuming document")-def _consume_wait_unmodified(file, num_tries=20, wait_time=1):+def _consume_wait_unmodified(file):mtime = -1current_try = 0- while current_try < num_tries:+ while current_try < settings.CONSUMER_POLLING_RETRY_COUNT:try:new_mtime = os.stat(file).st_mtimeexcept FileNotFoundError:@@ -82,7 +82,7 @@ def _consume_wait_unmodified(file, num_tries=20, wait_time=1):_consume(file)returnmtime = new_mtime- sleep(wait_time)+ sleep(settings.CONSUMER_POLLING_DELAY)current_try += 1logger.error(f"Timeout while waiting on file {file} to remain unmodified.")diff --git a/src/documents/tests/test_management_consumer.py b/src/documents/tests/test_management_consumer.pyindex b6a61a167..2111705e0 100644--- a/src/documents/tests/test_management_consumer.py+++ b/src/documents/tests/test_management_consumer.py@@ -203,7 +203,7 @@ class TestConsumer(DirectoriesMixin, ConsumerMixin, TransactionTestCase):self.assertRaises(CommandError, call_command, 'document_consumer', '--oneshot')-@override_settings(CONSUMER_POLLING=1)+@override_settings(CONSUMER_POLLING=1, CONSUMER_POLLING_DELAY=1, CONSUMER_POLLING_RETRY_COUNT=20)class TestConsumerPolling(TestConsumer):# just do all the tests with pollingpass@@ -215,8 +215,7 @@ class TestConsumerRecursive(TestConsumer):pass-@override_settings(CONSUMER_RECURSIVE=True)-@override_settings(CONSUMER_POLLING=1)+@override_settings(CONSUMER_RECURSIVE=True, CONSUMER_POLLING=1, CONSUMER_POLLING_DELAY=1, CONSUMER_POLLING_RETRY_COUNT=20)class TestConsumerRecursivePolling(TestConsumer):# just do all the tests with polling and recursivepass@@ -257,6 +256,6 @@ class TestConsumerTags(DirectoriesMixin, ConsumerMixin, TransactionTestCase):# their order.self.assertCountEqual(kwargs["override_tag_ids"], tag_ids)- @override_settings(CONSUMER_POLLING=1)+ @override_settings(CONSUMER_POLLING=1, CONSUMER_POLLING_DELAY=1, CONSUMER_POLLING_RETRY_COUNT=20)def test_consume_file_with_path_tags_polling(self):self.test_consume_file_with_path_tags()diff --git a/src/paperless/settings.py b/src/paperless/settings.pyindex abfb1afba..b0ce32305 100644--- a/src/paperless/settings.py+++ b/src/paperless/settings.py@@ -425,6 +425,12 @@ THREADS_PER_WORKER = os.getenv("PAPERLESS_THREADS_PER_WORKER", default_threads_pCONSUMER_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)+)+CONSUMER_DELETE_DUPLICATES = __get_boolean("PAPERLESS_CONSUMER_DELETE_DUPLICATES")CONSUMER_RECURSIVE = __get_boolean("PAPERLESS_CONSUMER_RECURSIVE")