summary refs log tree commit diff
path: root/synapse/storage/events.py
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2015-05-12 15:20:32 +0100
committerMark Haines <mjark@negativecurvature.net>2015-05-12 15:20:32 +0100
commit1fce36b11130eb0356c29a36d7f8fac1e0efce48 (patch)
tree249b8fc1067a0905ef17194279f2b0fc0940563a /synapse/storage/events.py
parentMerge pull request #148 from matrix-org/bugs/SYN-377 (diff)
parentErr, delete the right stuff (diff)
downloadsynapse-1fce36b11130eb0356c29a36d7f8fac1e0efce48.tar.xz
Merge pull request #149 from matrix-org/erikj/backfill
Backfill support
Diffstat (limited to 'synapse/storage/events.py')
-rw-r--r--synapse/storage/events.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index 626a5eaf6e..a5a6869079 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -135,19 +135,17 @@ class EventsStore(SQLBaseStore):
         outlier = event.internal_metadata.is_outlier()
 
         if not outlier:
-            self._store_state_groups_txn(txn, event, context)
-
             self._update_min_depth_for_room_txn(
                 txn,
                 event.room_id,
                 event.depth
             )
 
-        have_persisted = self._simple_select_one_onecol_txn(
+        have_persisted = self._simple_select_one_txn(
             txn,
-            table="event_json",
+            table="events",
             keyvalues={"event_id": event.event_id},
-            retcol="event_id",
+            retcols=["event_id", "outlier"],
             allow_none=True,
         )
 
@@ -162,7 +160,9 @@ class EventsStore(SQLBaseStore):
         # if we are persisting an event that we had persisted as an outlier,
         # but is no longer one.
         if have_persisted:
-            if not outlier:
+            if not outlier and have_persisted["outlier"]:
+                self._store_state_groups_txn(txn, event, context)
+
                 sql = (
                     "UPDATE event_json SET internal_metadata = ?"
                     " WHERE event_id = ?"
@@ -182,6 +182,9 @@ class EventsStore(SQLBaseStore):
                 )
             return
 
+        if not outlier:
+            self._store_state_groups_txn(txn, event, context)
+
         self._handle_prev_events(
             txn,
             outlier=outlier,