mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-03 23:15:44 +01:00
Fix reconciliation error for thumbnails for quotes.
This commit is contained in:
committed by
Cody Henthorne
parent
3ea7bf77e0
commit
8f47592fc0
@@ -422,26 +422,45 @@ class AttachmentTable(
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list that has any permanently-failed thumbnails removed.
|
||||
* Filters thumbnail snapshot entries down to only those that have at least one eligible attachment capable of thumbnail upload.
|
||||
*/
|
||||
fun filterPermanentlyFailedThumbnails(entries: Set<BackupMediaSnapshotTable.MediaEntry>): Set<BackupMediaSnapshotTable.MediaEntry> {
|
||||
fun filterThumbnailsWithoutEligibleAttachment(entries: Set<BackupMediaSnapshotTable.MediaEntry>): Set<BackupMediaSnapshotTable.MediaEntry> {
|
||||
if (entries.isEmpty()) {
|
||||
return entries
|
||||
}
|
||||
|
||||
val entriesByMediaName: MutableMap<String, BackupMediaSnapshotTable.MediaEntry> = entries
|
||||
.associateBy { MediaName.fromPlaintextHashAndRemoteKeyForThumbnail(it.plaintextHash, it.remoteKey).name }
|
||||
.toMutableMap()
|
||||
|
||||
val eligibleMediaNames: MutableSet<String> = mutableSetOf()
|
||||
|
||||
readableDatabase
|
||||
.select(DATA_HASH_END, REMOTE_KEY)
|
||||
.from(TABLE_NAME)
|
||||
.where("$DATA_HASH_END NOT NULL AND $REMOTE_KEY NOT NULL AND $ARCHIVE_THUMBNAIL_TRANSFER_STATE = ${ArchiveTransferState.PERMANENT_FAILURE.value}")
|
||||
.where(
|
||||
"""
|
||||
$DATA_HASH_END NOT NULL AND
|
||||
$REMOTE_KEY NOT NULL AND
|
||||
$DATA_FILE NOT NULL AND
|
||||
$TRANSFER_STATE = $TRANSFER_PROGRESS_DONE AND
|
||||
$QUOTE = 0 AND
|
||||
$ARCHIVE_THUMBNAIL_TRANSFER_STATE != ${ArchiveTransferState.PERMANENT_FAILURE.value}
|
||||
"""
|
||||
)
|
||||
.run()
|
||||
.forEach { cursor ->
|
||||
val hashEnd = cursor.requireNonNullString(DATA_HASH_END)
|
||||
val remoteKey = cursor.requireNonNullString(REMOTE_KEY)
|
||||
val thumbnailMediaName = MediaName.fromPlaintextHashAndRemoteKeyForThumbnail(Base64.decode(hashEnd), Base64.decode(remoteKey)).name
|
||||
|
||||
entriesByMediaName.remove(thumbnailMediaName)
|
||||
if (thumbnailMediaName in entriesByMediaName) {
|
||||
eligibleMediaNames += thumbnailMediaName
|
||||
}
|
||||
}
|
||||
|
||||
entriesByMediaName.keys.retainAll(eligibleMediaNames)
|
||||
|
||||
return entriesByMediaName.values.toSet()
|
||||
}
|
||||
|
||||
|
||||
@@ -617,7 +617,7 @@ class BackupMessagesJob private constructor(
|
||||
)
|
||||
}
|
||||
.toSet()
|
||||
.let { SignalDatabase.attachments.filterPermanentlyFailedThumbnails(it) }
|
||||
.let { SignalDatabase.attachments.filterThumbnailsWithoutEligibleAttachment(it) }
|
||||
}
|
||||
|
||||
class Factory : Job.Factory<BackupMessagesJob> {
|
||||
|
||||
Reference in New Issue
Block a user