Prevent infinite archive attachment reconciliation attempts after server storage quota disagreement.

This commit is contained in:
jeffrey-signal
2025-09-29 14:24:19 -04:00
committed by Michelle Tang
parent 415021eedf
commit a37209d8ba
3 changed files with 37 additions and 4 deletions

View File

@@ -82,6 +82,7 @@ class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
private const val KEY_BACKUP_EXPIRED_AND_DOWNGRADED = "backup.expired.and.downgraded"
private const val KEY_BACKUP_DELETION_STATE = "backup.deletion.state"
private const val KEY_REMOTE_STORAGE_GARBAGE_COLLECTION_PENDING = "backup.remoteStorageGarbageCollectionPending"
private const val KEY_ARCHIVE_ATTACHMENT_RECONCILIATION_ATTEMPTS = "backup.archiveAttachmentReconciliationAttempts"
private const val KEY_MEDIA_ROOT_BACKUP_KEY = "backup.mediaRootBackupKey"
@@ -393,10 +394,25 @@ class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
var remoteStorageGarbageCollectionPending
get() = store.getBoolean(KEY_REMOTE_STORAGE_GARBAGE_COLLECTION_PENDING, false)
set(value) {
store.beginWrite().putBoolean(KEY_REMOTE_STORAGE_GARBAGE_COLLECTION_PENDING, value)
store.beginWrite()
.putBoolean(KEY_REMOTE_STORAGE_GARBAGE_COLLECTION_PENDING, value)
.apply()
NoRemoteArchiveGarbageCollectionPendingConstraint.Observer.notifyListeners()
}
/**
* Tracks archive attachment reconciliation attempts to prevent infinite retries when we disagree with the server about available storage space.
*/
var archiveAttachmentReconciliationAttempts: Int
get() {
return store.getInteger(KEY_ARCHIVE_ATTACHMENT_RECONCILIATION_ATTEMPTS, 0)
}
set(value) {
store.beginWrite()
.putInteger(KEY_ARCHIVE_ATTACHMENT_RECONCILIATION_ATTEMPTS, value)
.apply()
}
/**
* When we are told by the server that we are out of storage space, we should show
* UX treatment to make the user aware of this.
@@ -416,6 +432,8 @@ class BackupValues(store: KeyValueStore) : SignalStoreValues(store) {
.putBoolean(KEY_NOT_ENOUGH_REMOTE_STORAGE_SPACE, false)
.putBoolean(KEY_NOT_ENOUGH_REMOTE_STORAGE_SPACE_DISPLAY_SHEET, false)
.apply()
archiveAttachmentReconciliationAttempts = 0
}
/**