Skip to content

Commit

Permalink
fix(sdk): Ensure a gap has been inserted before removing it.
Browse files Browse the repository at this point in the history
This patch fixes a bug where the code assumes a gap has been inserted,
and thus, is always present. But this isn't the case. If `prev_batch`
is `None`, a gap is not inserted, and so we cannot remove it. This patch
checks that `prev_batch` is `Some(_)`, which means the invariant is
correct, and the code can remove the gap.
  • Loading branch information
Hywan authored and bnjbvr committed Jan 9, 2025
1 parent 2a954e3 commit ddf4d57
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/matrix-sdk/src/event_cache/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ impl RoomEventCacheInner {

let added_unique_events = room_events.push_events(sync_timeline_events.clone());

if !added_unique_events {
if !added_unique_events && prev_batch.is_some() {
debug!(
"not storing previous batch token, because we deduplicated all new sync events"
);
Expand Down

0 comments on commit ddf4d57

Please sign in to comment.