Ignore errors from importing secrets from secret storage
This commit is contained in:
parent
59a8aaebff
commit
c3c5f80cac
3 changed files with 12 additions and 2 deletions
|
|
@ -10,6 +10,7 @@ package io.element.android.libraries.matrix.api.encryption
|
||||||
import io.element.android.libraries.matrix.api.exception.ClientException
|
import io.element.android.libraries.matrix.api.exception.ClientException
|
||||||
|
|
||||||
sealed class RecoveryException(message: String) : Exception(message) {
|
sealed class RecoveryException(message: String) : Exception(message) {
|
||||||
|
class Import(message: String) : RecoveryException(message)
|
||||||
class SecretStorage(message: String) : RecoveryException(message)
|
class SecretStorage(message: String) : RecoveryException(message)
|
||||||
data object BackupExistsOnServer : RecoveryException("BackupExistsOnServer")
|
data object BackupExistsOnServer : RecoveryException("BackupExistsOnServer")
|
||||||
data class Client(val exception: ClientException) : RecoveryException(exception.message ?: "Unknown error")
|
data class Client(val exception: ClientException) : RecoveryException(exception.message ?: "Unknown error")
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ fun Throwable.mapRecoveryException(): RecoveryException {
|
||||||
is RustRecoveryException.SecretStorage -> RecoveryException.SecretStorage(
|
is RustRecoveryException.SecretStorage -> RecoveryException.SecretStorage(
|
||||||
message = errorMessage
|
message = errorMessage
|
||||||
)
|
)
|
||||||
|
is RustRecoveryException.Import -> RecoveryException.Import(
|
||||||
|
message = errorMessage
|
||||||
|
)
|
||||||
is RustRecoveryException.BackupExistsOnServer -> RecoveryException.BackupExistsOnServer
|
is RustRecoveryException.BackupExistsOnServer -> RecoveryException.BackupExistsOnServer
|
||||||
is RustRecoveryException.Client -> RecoveryException.Client(
|
is RustRecoveryException.Client -> RecoveryException.Client(
|
||||||
source.mapClientException()
|
source.mapClientException()
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ import org.matrix.rustcomponents.sdk.UserIdentity
|
||||||
import org.matrix.rustcomponents.sdk.BackupUploadState as RustBackupUploadState
|
import org.matrix.rustcomponents.sdk.BackupUploadState as RustBackupUploadState
|
||||||
import org.matrix.rustcomponents.sdk.EnableRecoveryProgress as RustEnableRecoveryProgress
|
import org.matrix.rustcomponents.sdk.EnableRecoveryProgress as RustEnableRecoveryProgress
|
||||||
import org.matrix.rustcomponents.sdk.SteadyStateException as RustSteadyStateException
|
import org.matrix.rustcomponents.sdk.SteadyStateException as RustSteadyStateException
|
||||||
|
import org.matrix.rustcomponents.sdk.RecoveryException as RustRecoveryException
|
||||||
|
|
||||||
internal class RustEncryptionService(
|
internal class RustEncryptionService(
|
||||||
client: Client,
|
client: Client,
|
||||||
|
|
@ -182,8 +183,13 @@ internal class RustEncryptionService(
|
||||||
override suspend fun recover(recoveryKey: String): Result<Unit> = withContext(dispatchers.io) {
|
override suspend fun recover(recoveryKey: String): Result<Unit> = withContext(dispatchers.io) {
|
||||||
runCatchingExceptions {
|
runCatchingExceptions {
|
||||||
service.recover(recoveryKey)
|
service.recover(recoveryKey)
|
||||||
}.mapFailure {
|
}.recoverCatching {
|
||||||
it.mapRecoveryException()
|
if (it is RustRecoveryException.Import) {
|
||||||
|
// We ignore import errors because the user will be notified about them via the "Key storage out of sync" detection.
|
||||||
|
Unit
|
||||||
|
} else {
|
||||||
|
throw it.mapRecoveryException()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue