mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	added option for polling
This commit is contained in:
		| @@ -165,6 +165,12 @@ PAPERLESS_EMAIL_SECRET="" | |||||||
| # If you only specify PAPERLESS_TASK_WORKERS, paperless will adjust | # If you only specify PAPERLESS_TASK_WORKERS, paperless will adjust | ||||||
| # PAPERLESS_THREADS_PER_WORKER automatically. | # PAPERLESS_THREADS_PER_WORKER automatically. | ||||||
|  |  | ||||||
|  | # If paperless won't find documents added to your consume folder, it might | ||||||
|  | # not be able to automatically detect filesystem changes. In that case, | ||||||
|  | # specify a polling interval in seconds below, which will then cause paperless | ||||||
|  | # to periodically check your consumption directory for changes. | ||||||
|  | #PAPERLESS_CONSUMER_POLLING=10 | ||||||
|  |  | ||||||
|  |  | ||||||
| # When the consumer detects a duplicate document, it will not touch the | # When the consumer detects a duplicate document, it will not touch the | ||||||
| # original document. This default behavior can be changed here. | # original document. This default behavior can be changed here. | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ from django.core.management.base import BaseCommand | |||||||
| from django_q.tasks import async_task | from django_q.tasks import async_task | ||||||
| from watchdog.events import FileSystemEventHandler | from watchdog.events import FileSystemEventHandler | ||||||
| from watchdog.observers import Observer | from watchdog.observers import Observer | ||||||
|  | from watchdog.observers.polling import PollingObserver | ||||||
|  |  | ||||||
| try: | try: | ||||||
|     from inotify_simple import INotify, flags |     from inotify_simple import INotify, flags | ||||||
| @@ -75,7 +76,12 @@ class Command(BaseCommand): | |||||||
|                 async_task("documents.tasks.consume_file", entry.path, task_name=os.path.basename(entry.path)) |                 async_task("documents.tasks.consume_file", entry.path, task_name=os.path.basename(entry.path)) | ||||||
|  |  | ||||||
|         # Start the watchdog. Woof! |         # Start the watchdog. Woof! | ||||||
|         observer = Observer() |         if settings.CONSUMER_POLLING > 0: | ||||||
|  |             logging.getLogger(__name__).info('Using polling instead of file' | ||||||
|  |                                              'system notifications.') | ||||||
|  |             observer = PollingObserver(timeout=settings.CONSUMER_POLLING) | ||||||
|  |         else: | ||||||
|  |             observer = Observer() | ||||||
|         event_handler = Handler() |         event_handler = Handler() | ||||||
|         observer.schedule(event_handler, directory, recursive=True) |         observer.schedule(event_handler, directory, recursive=True) | ||||||
|         observer.start() |         observer.start() | ||||||
|   | |||||||
| @@ -286,13 +286,29 @@ TASK_WORKERS = int(os.getenv("PAPERLESS_TASK_WORKERS", default_task_workers())) | |||||||
| Q_CLUSTER = { | Q_CLUSTER = { | ||||||
|     'name': 'paperless', |     'name': 'paperless', | ||||||
|     'catch_up': False, |     'catch_up': False, | ||||||
|  |     'workers': TASK_WORKERS, | ||||||
|     'redis': os.getenv("PAPERLESS_REDIS", "redis://localhost:6379") |     'redis': os.getenv("PAPERLESS_REDIS", "redis://localhost:6379") | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | def default_threads_per_worker(): | ||||||
|  |     try: | ||||||
|  |         return max( | ||||||
|  |             math.floor(multiprocessing.cpu_count() / TASK_WORKERS), | ||||||
|  |             1 | ||||||
|  |         ) | ||||||
|  |     except NotImplementedError: | ||||||
|  |         return 1 | ||||||
|  |  | ||||||
|  |  | ||||||
|  | THREADS_PER_WORKER = os.getenv("PAPERLESS_THREADS_PER_WORKER", default_threads_per_worker()) | ||||||
|  |  | ||||||
| ############################################################################### | ############################################################################### | ||||||
| # Paperless Specific Settings                                                 # | # Paperless Specific Settings                                                 # | ||||||
| ############################################################################### | ############################################################################### | ||||||
|  |  | ||||||
|  | CONSUMER_POLLING = int(os.getenv("PAPERLESS_CONSUMER_POLLING", 0)) | ||||||
|  |  | ||||||
| CONSUMER_DELETE_DUPLICATES = __get_boolean("PAPERLESS_CONSUMER_DELETE_DUPLICATES") | CONSUMER_DELETE_DUPLICATES = __get_boolean("PAPERLESS_CONSUMER_DELETE_DUPLICATES") | ||||||
|  |  | ||||||
| # The default language that tesseract will attempt to use when parsing | # The default language that tesseract will attempt to use when parsing | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jonas Winkler
					Jonas Winkler