From 656223fbd3a87b278b8101175e0ac117a059a812 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 14 May 2015 14:26:35 +0100 Subject: [PATCH] Actually, we probably want to run this in a transaction --- synapse/storage/_base.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py index d896f5f918..e44821b5ec 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py @@ -881,32 +881,29 @@ class SQLBaseStore(object): allow_rejected=allow_rejected, ) - missing_events = [e for e in event_ids if e not in event_map] + missing_events_ids = [e for e in event_ids if e not in event_map] - def get_missing(txn=None): - missing_events = yield self._fetch_events( + def get_missing(txn): + missing_events = unwrap_deferred(self._fetch_events( txn, - missing_events, + missing_events_ids, check_redacted=check_redacted, get_prev_content=get_prev_content, allow_rejected=allow_rejected, - ) + )) event_map.update(missing_events) - defer.returnValue([ + return [ event_map[e_id] for e_id in event_ids if e_id in event_map and event_map[e_id] - ]) - - if missing_events and get_prev_content and not txn: - if get_prev_content and not txn: - # If we want prev_content then lets just jump into a txn. - res = yield self.runInteraction("_get_events", get_missing) - defer.returnValue(res) - - defer.returnValue(get_missing()) + ] + if not txn: + res = yield self.runInteraction("_get_events", get_missing) + defer.returnValue(res) + else: + defer.returnValue(get_missing(txn)) def _get_events_txn(self, txn, event_ids, check_redacted=True, get_prev_content=False, allow_rejected=False):