From 3378d18ca82acfd945b74cb9bf8e6f31c0163ef0 Mon Sep 17 00:00:00 2001 From: Julian Sparber Date: Tue, 22 Feb 2022 16:49:42 +0100 Subject: [PATCH] store: Add comment why we can ignore unexpected TimelineSlices --- crates/matrix-sdk-base/src/store/indexeddb_store.rs | 3 +++ crates/matrix-sdk-base/src/store/memory_store.rs | 3 +++ crates/matrix-sdk-base/src/store/sled_store.rs | 3 +++ 3 files changed, 9 insertions(+) diff --git a/crates/matrix-sdk-base/src/store/indexeddb_store.rs b/crates/matrix-sdk-base/src/store/indexeddb_store.rs index 161cd37d3..6dc9ec5e3 100644 --- a/crates/matrix-sdk-base/src/store/indexeddb_store.rs +++ b/crates/matrix-sdk-base/src/store/indexeddb_store.rs @@ -525,6 +525,9 @@ impl IndexeddbStore { .transpose()?; if let Some(mut metadata) = metadata { if !timeline.sync && Some(&timeline.start) != metadata.end.as_ref() { + // This should only happen when a developer adds a wrong timeline + // batch to the `StateChanges` or the server returns a wrong response + // to our request. warn!("Drop unexpected timeline batch for {}", room_id); return Ok(()); } diff --git a/crates/matrix-sdk-base/src/store/memory_store.rs b/crates/matrix-sdk-base/src/store/memory_store.rs index d84b447f2..ef173df72 100644 --- a/crates/matrix-sdk-base/src/store/memory_store.rs +++ b/crates/matrix-sdk-base/src/store/memory_store.rs @@ -290,6 +290,9 @@ impl MemoryStore { None } else if let Some(mut data) = self.room_timeline.get_mut(room) { if !timeline.sync && Some(&timeline.start) != data.end.as_ref() { + // This should only happen when a developer adds a wrong timeline + // batch to the `StateChanges` or the server returns a wrong response + // to our request. warn!("Drop unexpected timeline batch for {}", room); return Ok(()); } diff --git a/crates/matrix-sdk-base/src/store/sled_store.rs b/crates/matrix-sdk-base/src/store/sled_store.rs index 1070a1e45..a4aca43bb 100644 --- a/crates/matrix-sdk-base/src/store/sled_store.rs +++ b/crates/matrix-sdk-base/src/store/sled_store.rs @@ -1093,6 +1093,9 @@ impl SledStore { .transpose()?; if let Some(mut metadata) = metadata { if !timeline.sync && Some(&timeline.start) != metadata.end.as_ref() { + // This should only happen when a developer adds a wrong timeline + // batch to the `StateChanges` or the server returns a wrong response + // to our request. warn!("Drop unexpected timeline batch for {}", room_id); return Ok(()); }