Skip to content

Commit 1b5865a

Browse files
committed
disable indexing if auto sync disabled
1 parent db51a90 commit 1b5865a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

readthedocs/search/signals.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from __future__ import absolute_import
33
import django.dispatch
44
from django.dispatch import receiver
5+
from django_elasticsearch_dsl.apps import DEDConfig
56
from django_elasticsearch_dsl.registries import registry
67

78
from readthedocs.projects.models import HTMLFile
@@ -20,13 +21,17 @@ def index_html_file(instance_list, **_):
2021
'app_label': HTMLFile._meta.app_label,
2122
'model_name': HTMLFile.__name__,
2223
'document_class': str(PageDocument),
23-
'index_name': None, # No neeed to change the index name
24+
'index_name': None, # No need to change the index name
2425
'objects_id': [obj.id for obj in instance_list],
2526
}
2627

27-
index_objects_to_es_task(**kwargs)
28+
# Do not index if autosync is disabled globally
29+
if DEDConfig.autosync_enabled():
30+
index_objects_to_es_task(**kwargs)
2831

2932

3033
@receiver(bulk_post_delete, sender=HTMLFile)
3134
def remove_html_file(instance_list, **_):
32-
registry.delete(instance_list)
35+
# Do not index if autosync is disabled globally
36+
if DEDConfig.autosync_enabled():
37+
registry.delete(instance_list)

0 commit comments

Comments
 (0)