Fix received stickers for installed packs without a data_hash_end.

This commit is contained in:
Cody Henthorne
2025-08-28 12:04:43 -04:00
committed by GitHub
parent 8ce17e3e2d
commit 3bcfb5ab61
3 changed files with 358 additions and 2 deletions

View File

@@ -142,6 +142,7 @@ import org.thoughtcrime.securesms.database.helpers.migration.V284_SetPlaceholder
import org.thoughtcrime.securesms.database.helpers.migration.V285_AddEpochToCallLinksTable
import org.thoughtcrime.securesms.database.helpers.migration.V286_FixRemoteKeyEncoding
import org.thoughtcrime.securesms.database.helpers.migration.V287_FixInvalidArchiveState
import org.thoughtcrime.securesms.database.helpers.migration.V288_CopyStickerDataHashStartToEnd
import org.thoughtcrime.securesms.database.SQLiteDatabase as SignalSqliteDatabase
/**
@@ -289,10 +290,11 @@ object SignalDatabaseMigrations {
284 to V284_SetPlaceholderGroupFlag,
285 to V285_AddEpochToCallLinksTable,
286 to V286_FixRemoteKeyEncoding,
287 to V287_FixInvalidArchiveState
287 to V287_FixInvalidArchiveState,
288 to V288_CopyStickerDataHashStartToEnd
)
const val DATABASE_VERSION = 287
const val DATABASE_VERSION = 288
@JvmStatic
fun migrate(context: Application, db: SignalSqliteDatabase, oldVersion: Int, newVersion: Int) {

View File

@@ -0,0 +1,21 @@
/*
* Copyright 2025 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.thoughtcrime.securesms.database.helpers.migration
import android.app.Application
import org.thoughtcrime.securesms.database.SQLiteDatabase
/**
* Copy data_hash_start to data_hash_end for sticker attachments that have completed transfer.
*/
@Suppress("ClassName")
object V288_CopyStickerDataHashStartToEnd : SignalDatabaseMigration {
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
db.execSQL(
"UPDATE attachment SET data_hash_end = data_hash_start WHERE sticker_pack_id IS NOT NULL AND data_hash_start IS NOT NULL AND data_hash_end IS NULL AND transfer_state = 0"
)
}
}