Skip to content

Commit d6c2a63

Browse files
committed
refactor: Use the simplified locks in the encryption tasks
1 parent 4ebf505 commit d6c2a63

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

crates/matrix-sdk/src/encryption/backups/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ impl Backups {
10071007
room_id: OwnedRoomId,
10081008
event: Raw<OriginalSyncRoomEncryptedEvent>,
10091009
) {
1010-
let tasks = self.client.inner.e2ee.tasks.lock().unwrap();
1010+
let tasks = self.client.inner.e2ee.tasks.lock();
10111011
if let Some(task) = tasks.download_room_keys.as_ref() {
10121012
task.trigger_download_for_utd_event(room_id, event);
10131013
}
@@ -1016,7 +1016,7 @@ impl Backups {
10161016
/// Send a notification to the task which is responsible for uploading room
10171017
/// keys to the backup that it might have new room keys to back up.
10181018
pub(crate) fn maybe_trigger_backup(&self) {
1019-
let tasks = self.client.inner.e2ee.tasks.lock().unwrap();
1019+
let tasks = self.client.inner.e2ee.tasks.lock();
10201020

10211021
if let Some(tasks) = tasks.upload_room_keys.as_ref() {
10221022
tasks.trigger_upload();

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::{
2121
io::{Cursor, Read, Write},
2222
iter,
2323
path::PathBuf,
24-
sync::{Arc, Mutex as StdMutex},
24+
sync::Arc,
2525
};
2626

2727
use eyeball::{SharedObservable, Subscriber};
@@ -37,7 +37,7 @@ use matrix_sdk_base::crypto::{
3737
},
3838
CrossSigningBootstrapRequests, OlmMachine,
3939
};
40-
use matrix_sdk_common::executor::spawn;
40+
use matrix_sdk_common::{executor::spawn, locks::Mutex as StdMutex};
4141
use ruma::{
4242
api::client::{
4343
keys::{
@@ -131,7 +131,7 @@ impl EncryptionData {
131131
pub fn initialize_room_key_tasks(&self, client: &Arc<ClientInner>) {
132132
let weak_client = WeakClient::from_inner(client);
133133

134-
let mut tasks = self.tasks.lock().unwrap();
134+
let mut tasks = self.tasks.lock();
135135
tasks.upload_room_keys = Some(BackupUploadingTask::new(weak_client.clone()));
136136

137137
if self.encryption_settings.backup_download_strategy
@@ -147,7 +147,7 @@ impl EncryptionData {
147147
/// This should happen after the usual tasks have been set up and after the
148148
/// E2EE initialization tasks have been set up.
149149
pub fn initialize_recovery_state_update_task(&self, client: &Client) {
150-
let mut guard = self.tasks.lock().unwrap();
150+
let mut guard = self.tasks.lock();
151151

152152
let future = Recovery::update_state_after_backup_state_change(client);
153153
let join_handle = spawn(future);
@@ -1653,7 +1653,7 @@ impl Encryption {
16531653
/// allow for the initial upload of cross-signing keys without
16541654
/// authentication, rendering this parameter obsolete.
16551655
pub(crate) fn spawn_initialization_task(&self, auth_data: Option<AuthData>) {
1656-
let mut tasks = self.client.inner.e2ee.tasks.lock().unwrap();
1656+
let mut tasks = self.client.inner.e2ee.tasks.lock();
16571657

16581658
let this = self.clone();
16591659
tasks.setup_e2ee = Some(spawn(async move {
@@ -1679,7 +1679,7 @@ impl Encryption {
16791679
/// Waits for end-to-end encryption initialization tasks to finish, if any
16801680
/// was running in the background.
16811681
pub async fn wait_for_e2ee_initialization_tasks(&self) {
1682-
let task = self.client.inner.e2ee.tasks.lock().unwrap().setup_e2ee.take();
1682+
let task = self.client.inner.e2ee.tasks.lock().setup_e2ee.take();
16831683

16841684
if let Some(task) = task {
16851685
if let Err(err) = task.await {

0 commit comments

Comments
 (0)