From 3ef3a516b3f02de44a0fdf99caa164747385b2ff Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Mon, 30 Mar 2026 13:52:07 +0000 Subject: [PATCH] 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. --- .../thoughtcrime/securesms/backup/v2/BackupRepository.kt | 8 ++++++-- .../securesms/jobs/CopyAttachmentToArchiveJob.kt | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/BackupRepository.kt b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/BackupRepository.kt index 9d481adb75..cbf0bd89d1 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/BackupRepository.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/BackupRepository.kt @@ -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() { diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/CopyAttachmentToArchiveJob.kt b/app/src/main/java/org/thoughtcrime/securesms/jobs/CopyAttachmentToArchiveJob.kt index 531b7e3fef..866590bfd1 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/CopyAttachmentToArchiveJob.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/CopyAttachmentToArchiveJob.kt @@ -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) {