mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-17 07:23:21 +01:00
Prevent repeated storage-full notifications during backup.
When remote backup storage is full, hundreds of CopyAttachmentToArchiveJob instances each independently call markOutOfRemoteStorageSpaceError(), which re-posts the notification every time. Even though the notification ID is the same, each call re-alerts the user with sound and vibration. Guard markOutOfRemoteStorageSpaceError() to only post the notification once by checking the flag before proceeding, and move the flag-set before the notification post to prevent races. Also add an early exit in CopyAttachmentToArchiveJob to skip the network quota check when already marked as out of storage space.
This commit is contained in:
@@ -424,6 +424,12 @@ object BackupRepository {
|
||||
}
|
||||
|
||||
fun markOutOfRemoteStorageSpaceError() {
|
||||
if (SignalStore.backup.isNotEnoughRemoteStorageSpace) {
|
||||
return
|
||||
}
|
||||
|
||||
SignalStore.backup.markNotEnoughRemoteStorageSpace()
|
||||
|
||||
val context = AppDependencies.application
|
||||
|
||||
val pendingIntent = PendingIntent.getActivity(context, 0, AppSettingsActivity.remoteBackups(context), cancelCurrent())
|
||||
@@ -436,8 +442,6 @@ object BackupRepository {
|
||||
.build()
|
||||
|
||||
ServiceUtil.getNotificationManager(context).notify(NotificationIds.OUT_OF_REMOTE_STORAGE, notification)
|
||||
|
||||
SignalStore.backup.markNotEnoughRemoteStorageSpace()
|
||||
}
|
||||
|
||||
fun clearOutOfRemoteStorageSpaceError() {
|
||||
|
||||
@@ -86,6 +86,11 @@ class CopyAttachmentToArchiveJob private constructor(private val attachmentId: A
|
||||
return Result.success()
|
||||
}
|
||||
|
||||
if (SignalStore.backup.isNotEnoughRemoteStorageSpace) {
|
||||
Log.w(TAG, "[$attachmentId] Already marked as out of remote storage space. Failing.")
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
val attachment: DatabaseAttachment? = SignalDatabase.attachments.getAttachment(attachmentId)
|
||||
|
||||
if (attachment == null) {
|
||||
|
||||
Reference in New Issue
Block a user