]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: disable custom field signals during import in 2.13.0 (#8065)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Mon, 28 Oct 2024 01:43:24 +0000 (18:43 -0700)
committerGitHub <noreply@github.com>
Mon, 28 Oct 2024 01:43:24 +0000 (18:43 -0700)
src/documents/management/commands/document_importer.py
src/documents/signals/handlers.py

index 08812e9d0837977e66b5565b33f77df4537aaccd..22c626eba1a6c54f8b7b776a030aaed20b63adb5 100644 (file)
@@ -34,6 +34,7 @@ from documents.settings import EXPORTER_ARCHIVE_NAME
 from documents.settings import EXPORTER_CRYPTO_SETTINGS_NAME
 from documents.settings import EXPORTER_FILE_NAME
 from documents.settings import EXPORTER_THUMBNAIL_NAME
+from documents.signals.handlers import update_cf_instance_documents
 from documents.signals.handlers import update_filename_and_move_files
 from documents.utils import copy_file_with_basic_stats
 from paperless import version
@@ -242,6 +243,7 @@ class Command(CryptMixin, BaseCommand):
 
         self.decrypt_secret_fields()
 
+        # see /src/documents/signals/handlers.py
         with (
             disable_signal(
                 post_save,
@@ -253,6 +255,16 @@ class Command(CryptMixin, BaseCommand):
                 receiver=update_filename_and_move_files,
                 sender=Document.tags.through,
             ),
+            disable_signal(
+                post_save,
+                receiver=update_filename_and_move_files,
+                sender=CustomFieldInstance,
+            ),
+            disable_signal(
+                post_save,
+                receiver=update_cf_instance_documents,
+                sender=CustomField,
+            ),
         ):
             if settings.AUDIT_LOG_ENABLED:
                 auditlog.unregister(Document)
index eec6b135e7edad6280e4ee15f384481478eda363..0bf20fd5c7665cb2d3fb682664b28dac8a7a210c 100644 (file)
@@ -365,6 +365,7 @@ class CannotMoveFilesException(Exception):
     pass
 
 
+# should be disabled in /src/documents/management/commands/document_importer.py handle
 @receiver(models.signals.post_save, sender=CustomField)
 def update_cf_instance_documents(sender, instance: CustomField, **kwargs):
     """
@@ -379,6 +380,7 @@ def update_cf_instance_documents(sender, instance: CustomField, **kwargs):
             update_filename_and_move_files(sender, cf_instance)
 
 
+# should be disabled in /src/documents/management/commands/document_importer.py handle
 @receiver(models.signals.post_save, sender=CustomFieldInstance)
 @receiver(models.signals.m2m_changed, sender=Document.tags.through)
 @receiver(models.signals.post_save, sender=Document)