refactor(sdk): clean up errors in client encryption

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
This commit is contained in:
Michael Goldenberg
2026-03-14 22:08:44 -04:00
committed by Ivan Enderlin
parent ae72fcf663
commit 313e634996
2 changed files with 12 additions and 11 deletions
+4 -10
View File
@@ -1763,17 +1763,11 @@ impl Encryption {
&self,
max_backoff: Option<u32>,
) -> Result<Option<CrossProcessLockStoreGuardWithGeneration>, Error> {
let wrap_err = |e: CryptoStoreError| {
Error::CrossProcessLockError(Box::new(CrossProcessLockError::TryLock(Arc::new(e))))
};
if let Some(lock) = self.client.locks().cross_process_crypto_store_lock.get() {
let state = lock
.spin_lock(max_backoff)
.await
.map_err(|err| {
Error::CrossProcessLockError(Box::new(CrossProcessLockError::TryLock(
Arc::new(err),
)))
})?
.map_err(|err| Error::CrossProcessLockError(Box::new(err.into())))?;
let guard = match state {
let guard = match lock.spin_lock(max_backoff).await.map_err(wrap_err)?? {
CrossProcessLockState::Clean(guard) => guard,
CrossProcessLockState::Dirty(guard) => {
self.client.base_client().regenerate_olm(None).await?;
+8 -1
View File
@@ -26,7 +26,8 @@ use matrix_sdk_base::crypto::{
};
use matrix_sdk_base::{
Error as SdkBaseError, QueueWedgeError, RoomState, StoreError,
event_cache::store::EventCacheStoreError, media::store::MediaStoreError,
cross_process_lock::CrossProcessLockUnobtained, event_cache::store::EventCacheStoreError,
media::store::MediaStoreError,
};
use reqwest::Error as ReqwestError;
use ruma::{
@@ -481,6 +482,12 @@ impl From<CrossProcessLockError> for Error {
}
}
impl From<CrossProcessLockUnobtained> for Error {
fn from(error: CrossProcessLockUnobtained) -> Self {
CrossProcessLockError::from(error).into()
}
}
#[cfg(feature = "e2e-encryption")]
impl From<OlmError> for Error {
fn from(error: OlmError) -> Self {