@@ -57,7 +57,7 @@ use crate::{
5757 InviteAcceptanceDetails , RoomStateFilter , SessionMeta ,
5858 deserialized_responses:: DisplayName ,
5959 error:: { Error , Result } ,
60- event_cache:: store:: EventCacheStoreLock ,
60+ event_cache:: store:: { EventCacheStoreLock , EventCacheStoreLockState } ,
6161 media:: store:: MediaStoreLock ,
6262 response_processors:: { self as processors, Context } ,
6363 room:: {
@@ -1062,7 +1062,15 @@ impl BaseClient {
10621062 self . state_store . forget_room ( room_id) . await ?;
10631063
10641064 // Remove the room in the event cache store too.
1065- self . event_cache_store ( ) . lock ( ) . await ?. remove_room ( room_id) . await ?;
1065+ match self . event_cache_store ( ) . lock ( ) . await ? {
1066+ // If the lock is clear, we can do the operation as expected.
1067+ // If the lock is dirty, we can ignore to refresh the state, we just need to remove a
1068+ // room. Also, we must not mark the lock as non-dirty because other operations may be
1069+ // critical and may need to refresh the `EventCache`' state.
1070+ EventCacheStoreLockState :: Clean ( guard) | EventCacheStoreLockState :: Dirty ( guard) => {
1071+ guard. remove_room ( room_id) . await ?
1072+ }
1073+ }
10661074
10671075 Ok ( ( ) )
10681076 }
0 commit comments