File tree Expand file tree Collapse file tree 5 files changed +31
-11
lines changed
matrix-sdk-base/src/event_cache/store Expand file tree Collapse file tree 5 files changed +31
-11
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,10 @@ impl EventCacheStoreLock {
80
80
}
81
81
82
82
/// Acquire a spin lock (see [`CrossProcessStoreLock::spin_lock`]).
83
- pub async fn lock ( & self ) -> Result < EventCacheStoreLockGuard < ' _ > , LockStoreError > {
83
+ ///
84
+ /// It doesn't check whether the lock has been poisoned or not.
85
+ /// A lock has been poisoned if it's been acquired from another holder.
86
+ pub async fn lock_unchecked ( & self ) -> Result < EventCacheStoreLockGuard < ' _ > , LockStoreError > {
84
87
let cross_process_lock_guard = self . cross_process_lock . spin_lock ( None ) . await ?;
85
88
86
89
Ok ( EventCacheStoreLockGuard { cross_process_lock_guard, store : self . store . deref ( ) } )
Original file line number Diff line number Diff line change @@ -393,8 +393,13 @@ impl Media {
393
393
) -> Result < Vec < u8 > > {
394
394
// Read from the cache.
395
395
if use_cache {
396
- if let Some ( content) =
397
- self . client . event_cache_store ( ) . lock ( ) . await ?. get_media_content ( request) . await ?
396
+ if let Some ( content) = self
397
+ . client
398
+ . event_cache_store ( )
399
+ . lock_unchecked ( )
400
+ . await ?
401
+ . get_media_content ( request)
402
+ . await ?
398
403
{
399
404
return Ok ( content) ;
400
405
}
@@ -497,7 +502,7 @@ impl Media {
497
502
if use_cache {
498
503
self . client
499
504
. event_cache_store ( )
500
- . lock ( )
505
+ . lock_unchecked ( )
501
506
. await ?
502
507
. add_media_content ( request, content. clone ( ) )
503
508
. await ?;
@@ -512,7 +517,13 @@ impl Media {
512
517
///
513
518
/// * `request` - The `MediaRequest` of the content.
514
519
pub async fn remove_media_content ( & self , request : & MediaRequestParameters ) -> Result < ( ) > {
515
- Ok ( self . client . event_cache_store ( ) . lock ( ) . await ?. remove_media_content ( request) . await ?)
520
+ Ok ( self
521
+ . client
522
+ . event_cache_store ( )
523
+ . lock_unchecked ( )
524
+ . await ?
525
+ . remove_media_content ( request)
526
+ . await ?)
516
527
}
517
528
518
529
/// Delete all the media content corresponding to the given
@@ -522,7 +533,13 @@ impl Media {
522
533
///
523
534
/// * `uri` - The `MxcUri` of the files.
524
535
pub async fn remove_media_content_for_uri ( & self , uri : & MxcUri ) -> Result < ( ) > {
525
- Ok ( self . client . event_cache_store ( ) . lock ( ) . await ?. remove_media_content_for_uri ( uri) . await ?)
536
+ Ok ( self
537
+ . client
538
+ . event_cache_store ( )
539
+ . lock_unchecked ( )
540
+ . await ?
541
+ . remove_media_content_for_uri ( uri)
542
+ . await ?)
526
543
}
527
544
528
545
/// Get the file of the given media event content.
Original file line number Diff line number Diff line change @@ -1988,7 +1988,7 @@ impl Room {
1988
1988
. await ?;
1989
1989
1990
1990
if store_in_cache {
1991
- let cache_store_lock_guard = self . client . event_cache_store ( ) . lock ( ) . await ?;
1991
+ let cache_store_lock_guard = self . client . event_cache_store ( ) . lock_unchecked ( ) . await ?;
1992
1992
1993
1993
// A failure to cache shouldn't prevent the whole upload from finishing
1994
1994
// properly, so only log errors during caching.
Original file line number Diff line number Diff line change @@ -706,7 +706,7 @@ impl RoomSendQueue {
706
706
let data = room
707
707
. client ( )
708
708
. event_cache_store ( )
709
- . lock ( )
709
+ . lock_unchecked ( )
710
710
. await ?
711
711
. get_media_content ( & cache_key)
712
712
. await ?
Original file line number Diff line number Diff line change @@ -167,7 +167,7 @@ impl RoomSendQueue {
167
167
let client = room. client ( ) ;
168
168
let cache_store = client
169
169
. event_cache_store ( )
170
- . lock ( )
170
+ . lock_unchecked ( )
171
171
. await
172
172
. map_err ( RoomSendQueueStorageError :: LockError ) ?;
173
173
@@ -301,7 +301,7 @@ impl QueueStorage {
301
301
302
302
let cache_store = client
303
303
. event_cache_store ( )
304
- . lock ( )
304
+ . lock_unchecked ( )
305
305
. await
306
306
. map_err ( RoomSendQueueStorageError :: LockError ) ?;
307
307
@@ -530,7 +530,7 @@ impl QueueStorage {
530
530
// At this point, all the requests and dependent requests have been cleaned up.
531
531
// Perform the final step: empty the cache from the local items.
532
532
{
533
- let event_cache = client. event_cache_store ( ) . lock ( ) . await ?;
533
+ let event_cache = client. event_cache_store ( ) . lock_unchecked ( ) . await ?;
534
534
event_cache
535
535
. remove_media_content_for_uri ( & make_local_uri ( & handles. upload_file_txn ) )
536
536
. await ?;
You can’t perform that action at this time.
0 commit comments