mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-20 19:18:37 +00:00
Add error case for when you don't have enough disk space to create a backup.
This commit is contained in:
committed by
Alex Hart
parent
ccdec5113f
commit
dd8104bf61
@@ -88,6 +88,12 @@ fun BackupCreateErrorRow(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BackupValues.BackupCreationError.NOT_ENOUGH_DISK_SPACE -> {
|
||||
BackupAlertText {
|
||||
append(stringResource(R.string.BackupStatusRow__not_enough_disk_space, DateUtils.getDayPrecisionTimeString(context, locale, lastMessageCutoffTime)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.content.pm.PackageManager
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.NotificationManagerCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import okio.IOException
|
||||
import org.signal.core.util.PendingIntentFlags
|
||||
import org.signal.core.util.Stopwatch
|
||||
import org.signal.core.util.isNotNullOrBlank
|
||||
@@ -445,6 +446,7 @@ class BackupMessagesJob private constructor(
|
||||
val attachmentInfoBuffer: MutableSet<ArchiveAttachmentInfo> = mutableSetOf()
|
||||
val messageInclusionCutoffTime = SignalStore.backup.messageCuttoffDuration?.let { currentTime - it.inWholeMilliseconds } ?: 0
|
||||
|
||||
try {
|
||||
BackupRepository.exportForSignalBackup(
|
||||
outputStream = outputStream,
|
||||
messageBackupKey = backupKey,
|
||||
@@ -463,6 +465,15 @@ class BackupMessagesJob private constructor(
|
||||
attachmentInfoBuffer.clear()
|
||||
}
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
if (e.message?.contains("ENOSPC") == true) {
|
||||
Log.w(TAG, "Not enough space to make a backup!", e, true)
|
||||
tempBackupFile.delete()
|
||||
this.dataFile = ""
|
||||
BackupRepository.markBackupCreationFailed(BackupValues.BackupCreationError.NOT_ENOUGH_DISK_SPACE)
|
||||
return BackupFileResult.Failure
|
||||
}
|
||||
}
|
||||
|
||||
if (attachmentInfoBuffer.isNotEmpty()) {
|
||||
SignalDatabase.backupMediaSnapshots.writePendingMediaEntries(attachmentInfoBuffer.toFullSizeMediaEntries(mediaRootBackupKey))
|
||||
|
||||
@@ -606,7 +606,10 @@ class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
|
||||
VALIDATION(2),
|
||||
|
||||
/** The backup file itself is too large. The only resolution would be for the user to delete some number of messages. */
|
||||
BACKUP_FILE_TOO_LARGE(3);
|
||||
BACKUP_FILE_TOO_LARGE(3),
|
||||
|
||||
/** We do not have enough space on the device to create the backup file. */
|
||||
NOT_ENOUGH_DISK_SPACE(4);
|
||||
|
||||
companion object {
|
||||
|
||||
|
||||
@@ -8058,6 +8058,8 @@
|
||||
<string name="BackupStatusRow__backup_file_too_large">The number of messages you have exceeds the storage limit. Delete some messages and try again.</string>
|
||||
<!-- Text displayed when we're not backing up all messages. The placeholder represents the cutoff date for the messages we're backing up. -->
|
||||
<string name="BackupStatusRow__not_backing_up_old_messages">Messages sent or received before %1$s are not being backed up.</string>
|
||||
<!-- Text displayed when we failed to create a backup because of low disk space. -->
|
||||
<string name="BackupStatusRow__not_enough_disk_space">Your backup couldn\'t be completed because you are low on disk space. Free up space on your device and try again.</string>
|
||||
<!-- Text displayed in a row to learn more about why a backup failed -->
|
||||
<string name="BackupStatusRow__learn_more">Learn more</string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user