Skip to content

Commit 4fe2302

Browse files
committed
!append_events_locked_impl: lock is mandatory
1 parent 4331406 commit 4fe2302

File tree

1 file changed

+3
-9
lines changed
  • crates/matrix-sdk/src/event_cache

1 file changed

+3
-9
lines changed

crates/matrix-sdk/src/event_cache/mod.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ impl RoomEventCacheInner {
538538

539539
// Push the new events.
540540
self.append_events_locked_impl(
541-
Some(room_events),
541+
room_events,
542542
events,
543543
prev_batch,
544544
account_data,
@@ -558,9 +558,8 @@ impl RoomEventCacheInner {
558558
ephemeral: Vec<Raw<AnySyncEphemeralRoomEvent>>,
559559
ambiguity_changes: BTreeMap<OwnedEventId, AmbiguityChange>,
560560
) -> Result<()> {
561-
// Push the new events.
562561
self.append_events_locked_impl(
563-
None,
562+
self.events.write().await,
564563
events,
565564
prev_batch,
566565
account_data,
@@ -577,7 +576,7 @@ impl RoomEventCacheInner {
577576
/// This is a private implementation. It must not be exposed publicly.
578577
async fn append_events_locked_impl(
579578
&self,
580-
room_events: Option<RwLockWriteGuard<'_, RoomEvents>>,
579+
mut room_events: RwLockWriteGuard<'_, RoomEvents>,
581580
events: Vec<SyncTimelineEvent>,
582581
prev_batch: Option<String>,
583582
account_data: Vec<Raw<AnyRoomAccountDataEvent>>,
@@ -593,11 +592,6 @@ impl RoomEventCacheInner {
593592
return Ok(());
594593
}
595594

596-
let mut room_events = match room_events {
597-
Some(room_events) => room_events,
598-
None => self.events.write().await,
599-
};
600-
601595
// Add the previous back-pagination token (if present), followed by the timeline
602596
// events themselves.
603597
{

0 commit comments

Comments
 (0)