File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
crates/matrix-sdk-sqlite/src Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -627,6 +627,13 @@ impl EventCacheStore for SqliteEventCacheStore {
627
627
room_id : & RoomId ,
628
628
events : Vec < OwnedEventId > ,
629
629
) -> Result < Vec < OwnedEventId > , Self :: Error > {
630
+ // If there's no events for which we want to check duplicates, we can return
631
+ // early. It's not only an optimization to do so: it's required, otherwise the
632
+ // `repeat_vars` call below will panic.
633
+ if events. is_empty ( ) {
634
+ return Ok ( Vec :: new ( ) ) ;
635
+ }
636
+
630
637
// Select all events that exist in the store, i.e. the duplicates.
631
638
let room_id = room_id. to_owned ( ) ;
632
639
let hashed_room_id = self . encode_key ( keys:: LINKED_CHUNKS , & room_id) ;
@@ -1805,6 +1812,15 @@ mod tests {
1805
1812
let chunks = store. reload_linked_chunk ( room_id) . await . unwrap ( ) ;
1806
1813
assert ! ( chunks. is_empty( ) ) ;
1807
1814
}
1815
+
1816
+ #[ async_test]
1817
+ async fn test_filter_duplicate_events_no_events ( ) {
1818
+ let store = get_event_cache_store ( ) . await . expect ( "creating cache store failed" ) ;
1819
+
1820
+ let room_id = * DEFAULT_TEST_ROOM_ID ;
1821
+ let duplicates = store. filter_duplicated_events ( room_id, Vec :: new ( ) ) . await . unwrap ( ) ;
1822
+ assert ! ( duplicates. is_empty( ) ) ;
1823
+ }
1808
1824
}
1809
1825
1810
1826
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments