From d8e27600be59f45efb7958d88da440e1cf09a4bc Mon Sep 17 00:00:00 2001 From: Jonas Winkler Date: Sun, 22 Nov 2020 13:53:19 +0100 Subject: [PATCH] workaround for a bug in django-q: task results with too long names would not show up in the result lists. --- src/documents/forms.py | 2 +- src/documents/management/commands/document_consumer.py | 4 ++-- src/paperless_mail/mail.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/documents/forms.py b/src/documents/forms.py index 0471a8312..63dd307b2 100644 --- a/src/documents/forms.py +++ b/src/documents/forms.py @@ -56,4 +56,4 @@ class UploadForm(forms.Form): async_task("documents.tasks.consume_file", f.name, override_filename=original_filename, - task_name=os.path.basename(original_filename)) + task_name=os.path.basename(original_filename)[:100]) diff --git a/src/documents/management/commands/document_consumer.py b/src/documents/management/commands/document_consumer.py index 70c36a03c..05711ebd8 100644 --- a/src/documents/management/commands/document_consumer.py +++ b/src/documents/management/commands/document_consumer.py @@ -21,7 +21,7 @@ class Handler(FileSystemEventHandler): try: async_task("documents.tasks.consume_file", file, - task_name=os.path.basename(file)) + task_name=os.path.basename(file)[:100]) except Exception as e: # Catch all so that the consumer won't crash. logging.getLogger(__name__).error( @@ -71,7 +71,7 @@ class Command(BaseCommand): if entry.is_file(): async_task("documents.tasks.consume_file", entry.path, - task_name=os.path.basename(entry.path)) + task_name=os.path.basename(entry.path)[:100]) # Start the watchdog. Woof! if settings.CONSUMER_POLLING > 0: diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index dfdfa09ce..1ce4fe825 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -286,7 +286,7 @@ class MailAccountHandler(LoggingMixin): override_correspondent_id=correspondent.id if correspondent else None, # NOQA: E501 override_document_type_id=doc_type.id if doc_type else None, # NOQA: E501 override_tag_ids=[tag.id] if tag else None, - task_name=f"Mail: {att.filename}" + task_name=att.filename[:100] ) processed_attachments += 1