@@ -232,6 +232,11 @@ impl EventCache {
232232 room_id : & RoomId ,
233233 events : Vec < ( OwnedEventId , DecryptedRoomEvent , Option < Vec < Action > > ) > ,
234234 ) -> Result < ( ) , EventCacheError > {
235+ if events. is_empty ( ) {
236+ trace ! ( "No events were redecrypted or updated, nothing to replace" ) ;
237+ return Ok ( ( ) ) ;
238+ }
239+
235240 // Get the cache for this particular room and lock the state for the duration of
236241 // the decryption.
237242 let ( room_cache, _drop_handles) = self . for_room ( room_id) . await ?;
@@ -240,7 +245,6 @@ impl EventCache {
240245 let event_ids: BTreeSet < _ > =
241246 events. iter ( ) . cloned ( ) . map ( |( event_id, _, _) | event_id) . collect ( ) ;
242247
243- trace ! ( ?event_ids, "Replacing successfully re-decrypted events" ) ;
244248
245249 for ( event_id, decrypted, actions) in events {
246250 // The event isn't in the cache, nothing to replace. Realistically this can't
@@ -333,7 +337,7 @@ impl EventCache {
333337
334338 /// Attempt to redecrypt events after a room key with the given session ID
335339 /// has been received.
336- #[ instrument( skip_all, fields( room_key_info ) ) ]
340+ #[ instrument( skip_all, fields( room_id , session_id ) ) ]
337341 async fn retry_decryption (
338342 & self ,
339343 room_id : & RoomId ,
@@ -367,13 +371,21 @@ impl EventCache {
367371 }
368372 }
369373
374+ let event_ids: BTreeSet < _ > =
375+ decrypted_events. iter ( ) . map ( |( event_id, _, _) | event_id) . collect ( ) ;
376+
377+ if !event_ids. is_empty ( ) {
378+ trace ! ( ?event_ids, "Successfully redecrypted events" ) ;
379+ }
380+
370381 // Replace the events and notify listeners that UTDs have been replaced with
371382 // decrypted events.
372383 self . on_resolved_utds ( room_id, decrypted_events) . await ?;
373384
374385 Ok ( ( ) )
375386 }
376387
388+ #[ instrument( skip_all, fields( room_id, session_id) ) ]
377389 async fn update_encryption_info (
378390 & self ,
379391 room_id : & RoomId ,
@@ -406,6 +418,13 @@ impl EventCache {
406418 }
407419 }
408420
421+ let event_ids: BTreeSet < _ > =
422+ updated_events. iter ( ) . map ( |( event_id, _, _) | event_id) . collect ( ) ;
423+
424+ if !event_ids. is_empty ( ) {
425+ trace ! ( ?event_ids, "Replacing the encryption info of some events" ) ;
426+ }
427+
409428 self . on_resolved_utds ( room_id, updated_events) . await ?;
410429
411430 Ok ( ( ) )
0 commit comments