mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-26 12:44:38 +00:00
Ensure that we clear incrementalMac's that will be invalidated during archive.
This commit is contained in:
committed by
Michelle Tang
parent
bed718347c
commit
a234896438
@@ -683,6 +683,29 @@ class AttachmentTable(
|
||||
return count
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears incrementalMac's for any attachments that still need to be uploaded.
|
||||
* This is important because when we upload an attachment to the archive CDN, we'll be re-encrypting it, and so the incrementalMac will end up changing.
|
||||
* So we want to be sure that we don't write a potentially-invalid incrementalMac in the meantime.
|
||||
*/
|
||||
fun clearIncrementalMacsForAttachmentsThatNeedArchiveUpload(): Int {
|
||||
return writableDatabase
|
||||
.update(TABLE_NAME)
|
||||
.values(
|
||||
REMOTE_INCREMENTAL_DIGEST to null,
|
||||
REMOTE_INCREMENTAL_DIGEST_CHUNK_SIZE to 0
|
||||
)
|
||||
.where(
|
||||
"""
|
||||
$ARCHIVE_TRANSFER_STATE = ${ArchiveTransferState.NONE.value} AND
|
||||
$DATA_FILE NOT NULL AND
|
||||
$TRANSFER_STATE = $TRANSFER_PROGRESS_DONE AND
|
||||
$REMOTE_INCREMENTAL_DIGEST NOT NULL
|
||||
"""
|
||||
)
|
||||
.run()
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to [getAttachmentsThatNeedArchiveUpload], but returns if the list would be non-null in a more efficient way.
|
||||
*/
|
||||
|
||||
@@ -182,6 +182,9 @@ class BackupMessagesJob private constructor(
|
||||
SignalDatabase.attachments.createRemoteKeyForAttachmentsThatNeedArchiveUpload().takeIf { it > 0 }?.let { count -> Log.w(TAG, "Needed to create $count remote keys.") }
|
||||
stopwatch.split("keygen")
|
||||
|
||||
SignalDatabase.attachments.clearIncrementalMacsForAttachmentsThatNeedArchiveUpload().takeIf { it > 0 }?.let { count -> Log.w(TAG, "Needed to clear $count incrementalMacs.") }
|
||||
stopwatch.split("clear-incmac")
|
||||
|
||||
if (isCanceled) {
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user