summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-05-14 14:26:35 +0100
committerErik Johnston <erik@matrix.org>2015-05-14 14:26:35 +0100
commit656223fbd3a87b278b8101175e0ac117a059a812 (patch)
treea02b009025bcfb55d9e43f5d3a501baa29aa293f /synapse
parentPreemptively jump into a transaction if we ask for get_prev_content (diff)
downloadsynapse-656223fbd3a87b278b8101175e0ac117a059a812.tar.xz
Actually, we probably want to run this in a transaction
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/_base.py27
1 files 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):