BackupState.DISABLED has been removed. Now when the value is UNKNOWN, the app need to invoke EncryptionService.doesBackupExistOnServer() to check if a Backup exists.

This commit is contained in:
Benoit Marty 2023-11-17 17:31:22 +01:00
parent fe1ffe3aae
commit d352f14665
9 changed files with 57 additions and 12 deletions

View file

@ -31,6 +31,5 @@ enum class BackupState {
RESUMING,
ENABLED,
DOWNLOADING,
DISABLING,
DISABLED;
DISABLING;
}

View file

@ -40,6 +40,8 @@ interface EncryptionService {
suspend fun disableRecovery(): Result<Unit>
suspend fun doesBackupExistOnServer(): Result<Boolean>
/**
* Note: accept bot recoveryKey and passphrase.
*/

View file

@ -29,7 +29,6 @@ class BackupStateMapper {
RustBackupState.ENABLED -> BackupState.ENABLED
RustBackupState.DOWNLOADING -> BackupState.DOWNLOADING
RustBackupState.DISABLING -> BackupState.DISABLING
RustBackupState.DISABLED -> BackupState.DISABLED
}
}
}

View file

@ -130,6 +130,12 @@ internal class RustEncryptionService(
}
}
override suspend fun doesBackupExistOnServer(): Result<Boolean> = withContext(dispatchers.io) {
runCatching {
service.backupExistsOnServer()
}
}
override fun waitForBackupUploadSteadyState(): Flow<BackupUploadState> {
return callbackFlow {
runCatching {

View file

@ -52,6 +52,10 @@ class FakeEncryptionService : EncryptionService {
return Result.success(Unit)
}
override suspend fun doesBackupExistOnServer(): Result<Boolean> = simulateLongTask {
return Result.success(true)
}
override suspend fun fixRecoveryIssues(recoveryKey: String): Result<Unit> = simulateLongTask {
fixRecoveryIssuesFailure?.let { return Result.failure(it) }
return Result.success(Unit)