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

Flush caches before updating index

This is mostly needed for testsuite, but might be triggered in some
complex setups as well.
parent 03734d41
......@@ -21,7 +21,8 @@
from trans.management.commands import WeblateCommand
from lang.models import Language
from trans.search import (
update_index, create_source_index, create_target_index
update_index, create_source_index, create_target_index,
flush_caches
)
from optparse import make_option
......@@ -47,4 +48,6 @@ class Command(WeblateCommand):
units = self.get_units(*args, **options)
flush_caches()
update_index(units)
......@@ -112,6 +112,13 @@ def update_index(units, source_units=None):
)
def flush_caches():
'''
Flushes internal caches.
'''
FULLTEXT_INDEX.flush_caches()
class Index(object):
'''
Class to manage index readers and writers.
......@@ -177,5 +184,11 @@ class Index(object):
'''
return self.target(lang).searcher()
def flush_caches():
'''
Flushes internal caches.
'''
self._source = None
self._target = {}
FULLTEXT_INDEX = Index()
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