diff --git a/mayan/apps/document_indexing/__init__.py b/mayan/apps/document_indexing/__init__.py index 64c21e01bf..e9d71c51f3 100644 --- a/mayan/apps/document_indexing/__init__.py +++ b/mayan/apps/document_indexing/__init__.py @@ -29,13 +29,11 @@ def document_index_delete(sender, **kwargs): @receiver(post_save, dispatch_uid='document_metadata_index_update', sender=DocumentMetadata) def document_metadata_index_update(sender, **kwargs): task_index_document.apply_async(kwargs=dict(document_id=kwargs['instance'].document.pk), queue='indexing') - task_delete_empty_index_nodes.apply_async(queue='indexing') @receiver(post_delete, dispatch_uid='document_metadata_index_post_delete', sender=DocumentMetadata) def document_metadata_index_post_delete(sender, **kwargs): task_index_document.apply_async(kwargs=dict(document_id=kwargs['instance'].document.pk), queue='indexing') - task_delete_empty_index_nodes.apply_async(queue='indexing') register_maintenance_links([rebuild_index_instances], namespace='document_indexing', title=_(u'Indexes')) diff --git a/mayan/apps/document_indexing/api.py b/mayan/apps/document_indexing/api.py index 02055786de..a0c0c46004 100644 --- a/mayan/apps/document_indexing/api.py +++ b/mayan/apps/document_indexing/api.py @@ -24,6 +24,8 @@ def index_document(document): for index_node in IndexInstanceNode.objects.filter(documents=document): index_node.documents.remove(document) + delete_empty_index_nodes() + # Only update indexes where the document type is found or that do not have any document type specified # TODO: explicit document type selection, none != all for index in Index.objects.filter(Q(enabled=True) & (Q(document_types=None) | Q(document_types=document.document_type))):