Actually, we probably want to run this in a transaction

This commit is contained in:
Erik Johnston 2015-05-14 14:26:35 +01:00
parent 2f7f8e1c2b
commit 656223fbd3

View File

@ -881,32 +881,29 @@ class SQLBaseStore(object):
allow_rejected=allow_rejected, 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): def get_missing(txn):
missing_events = yield self._fetch_events( missing_events = unwrap_deferred(self._fetch_events(
txn, txn,
missing_events, missing_events_ids,
check_redacted=check_redacted, check_redacted=check_redacted,
get_prev_content=get_prev_content, get_prev_content=get_prev_content,
allow_rejected=allow_rejected, allow_rejected=allow_rejected,
) ))
event_map.update(missing_events) event_map.update(missing_events)
defer.returnValue([ return [
event_map[e_id] for e_id in event_ids event_map[e_id] for e_id in event_ids
if e_id in event_map and event_map[e_id] if e_id in event_map and event_map[e_id]
]) ]
if missing_events and get_prev_content and not txn: if 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) res = yield self.runInteraction("_get_events", get_missing)
defer.returnValue(res) defer.returnValue(res)
else:
defer.returnValue(get_missing()) defer.returnValue(get_missing(txn))
def _get_events_txn(self, txn, event_ids, check_redacted=True, def _get_events_txn(self, txn, event_ids, check_redacted=True,
get_prev_content=False, allow_rejected=False): get_prev_content=False, allow_rejected=False):