mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 11:26:09 -04:00
Run the background updates when starting synapse.
This commit is contained in:
parent
2ede7aa8a1
commit
a412b9a465
4 changed files with 67 additions and 10 deletions
|
@ -29,6 +29,11 @@ class SearchStore(BackgroundUpdateStore):
|
|||
|
||||
EVENT_SEARCH_UPDATE_NAME = "event_search"
|
||||
|
||||
def __init__(self, hs):
|
||||
super(SearchStore, self).__init__(hs)
|
||||
self.register_background_update_handler(
|
||||
self.EVENT_SEARCH_UPDATE_NAME, self._background_reindex_search
|
||||
)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _background_reindex_search(self, progress, batch_size):
|
||||
|
@ -74,7 +79,7 @@ class SearchStore(BackgroundUpdateStore):
|
|||
elif event.type == "m.room.name":
|
||||
key = "content.name"
|
||||
value = content["name"]
|
||||
except Exception:
|
||||
except (KeyError, AttributeError):
|
||||
# If the event is missing a necessary field then
|
||||
# skip over it.
|
||||
continue
|
||||
|
@ -96,7 +101,7 @@ class SearchStore(BackgroundUpdateStore):
|
|||
raise Exception("Unrecognized database engine")
|
||||
|
||||
for index in range(0, len(event_search_rows), INSERT_CLUMP_SIZE):
|
||||
clump = event_search_rows[index : index + INSERT_CLUMP_SIZE)
|
||||
clump = event_search_rows[index:index + INSERT_CLUMP_SIZE]
|
||||
txn.execute_many(sql, clump)
|
||||
|
||||
progress = {
|
||||
|
@ -116,7 +121,7 @@ class SearchStore(BackgroundUpdateStore):
|
|||
)
|
||||
|
||||
if result is None:
|
||||
yield _end_background_update(self.EVENT_SEARCH_UPDATE_NAME)
|
||||
yield self._end_background_update(self.EVENT_SEARCH_UPDATE_NAME)
|
||||
|
||||
defer.returnValue(result)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue