Detect storage space issues during restore.

This commit is contained in:
Alex Hart
2024-11-14 13:26:30 -04:00
committed by Greyson Parrelli
parent b4472833b8
commit 7f1a866e79
14 changed files with 163 additions and 35 deletions

View File

@@ -78,7 +78,7 @@ class MediaRestoreProgressBanner(private val listener: RestoreProgressBannerList
)
}
private fun getActiveRestoreFlow(): Flow<BackupStatusData.RestoringMedia> {
private fun getActiveRestoreFlow(): Flow<BackupStatusData> {
val flow: Flow<Unit> = callbackFlow {
val onChange = { trySend(Unit) }
@@ -115,8 +115,13 @@ class MediaRestoreProgressBanner(private val listener: RestoreProgressBannerList
val totalRestoreSize = SignalStore.backup.totalRestorableAttachmentSize
val remainingAttachmentSize = SignalDatabase.attachments.getRemainingRestorableAttachmentSize()
val completedBytes = totalRestoreSize - remainingAttachmentSize
val availableBytes = SignalStore.backup.spaceAvailableOnDiskBytes
BackupStatusData.RestoringMedia(completedBytes.bytes, totalRestoreSize.bytes)
if (availableBytes > -1L && remainingAttachmentSize > availableBytes) {
BackupStatusData.NotEnoughFreeSpace(requiredSpace = remainingAttachmentSize.bytes)
} else {
BackupStatusData.RestoringMedia(completedBytes.bytes, totalRestoreSize.bytes)
}
}
}
}