summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-08-15 16:05:46 +0100
committerErik Johnston <erik@matrix.org>2014-08-15 16:05:46 +0100
commitcd2967d271d8127b6f6ebf4aa7a671d3eeca3c59 (patch)
tree98183707c6c9669f9c9819ef314cc6515ff4e755
parentActually use MAX_STREAM_SIZE constant. (diff)
downloadsynapse-cd2967d271d8127b6f6ebf4aa7a671d3eeca3c59.tar.xz
Fix bug when generating a key when get_room_events_stream returned zero rows
-rw-r--r--synapse/storage/stream.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py
index 47f05a41bd..bb56f0763d 100644
--- a/synapse/storage/stream.py
+++ b/synapse/storage/stream.py
@@ -89,10 +89,14 @@ class StreamStore(SQLBaseStore):
 
         ret = [self._parse_event_from_row(r) for r in rows]
 
-        if from_key < to_key:
-            key = max([r["ordering"] for r in rows])
+
+        if rows:
+            if from_key < to_key:
+                key = max([r["ordering"] for r in rows])
+            else:
+                key = min([r["ordering"] for r in rows])
         else:
-            key = min([r["ordering"] for r in rows])
+            key = to_key
 
         defer.returnValue((ret, key))