Commit d257aaff authored by Michal Čihař's avatar Michal Čihař

Except that index update entry does not exist

There usually should not be existing entry and get_or_create is too
expensive then - it needs extra select to figure out that there is
nothing. So be rather optimistic and recover from error when needed.
parent 19454b5a
......@@ -21,6 +21,7 @@
from django.db import models
from weblate import appsettings
from django.db.models import Q
from django.db import IntegrityError
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
from django.contrib import messages
......@@ -214,7 +215,10 @@ class UnitManager(models.Manager):
'''
if appsettings.OFFLOAD_INDEXING:
from trans.models.unitdata import IndexUpdate
IndexUpdate.objects.get_or_create(unit=unit, source=source)
try:
IndexUpdate.objects.create(unit=unit, source=source)
except IntegrityError:
pass
return
writer_target = FULLTEXT_INDEX.target_writer(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment