Ensure that restore status gets reset on failure.

This commit is contained in:
Greyson Parrelli
2025-11-13 11:47:03 -05:00
committed by Cody Henthorne
parent 9997ac2ef9
commit 2a3888472f
2 changed files with 11 additions and 1 deletions

View File

@@ -91,6 +91,12 @@ object ArchiveRestoreProgress {
update()
}
fun onRestoreFailed() {
Log.i(TAG, "onRestoreFailed")
SignalStore.backup.restoreState = RestoreState.NONE
update()
}
fun onStartMediaRestore() {
Log.i(TAG, "onStartMediaRestore")
SignalStore.backup.restoreState = RestoreState.CALCULATING_MEDIA

View File

@@ -2151,9 +2151,13 @@ object BackupRepository {
try {
DataRestoreConstraint.isRestoringData = true
return withContext(Dispatchers.IO) {
return@withContext BackupProgressService.start(context, context.getString(R.string.BackupProgressService_title)).use {
val result = BackupProgressService.start(context, context.getString(R.string.BackupProgressService_title)).use {
restoreRemoteBackup(controller = it, cancellationSignal = { !isActive })
}
if (result !is RemoteRestoreResult.Success) {
ArchiveRestoreProgress.onRestoreFailed()
}
return@withContext result
}
} finally {
DataRestoreConstraint.isRestoringData = false