From f8846e3593ecc7d9cfb91695498fc7f54a144f64 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Tue, 17 Sep 2024 23:02:26 -0400 Subject: [PATCH] Clear attachment uploadTimestamps. --- .../helpers/SignalDatabaseMigrations.kt | 6 ++++-- .../migration/V247_ClearUploadTimestamp.kt | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V247_ClearUploadTimestamp.kt diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SignalDatabaseMigrations.kt b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SignalDatabaseMigrations.kt index 9415e50b6f..d2ad98335c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SignalDatabaseMigrations.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/SignalDatabaseMigrations.kt @@ -105,6 +105,7 @@ import org.thoughtcrime.securesms.database.helpers.migration.V243_MessageFullTex import org.thoughtcrime.securesms.database.helpers.migration.V244_AttachmentRemoteIv import org.thoughtcrime.securesms.database.helpers.migration.V245_DeletionTimestampOnCallLinks import org.thoughtcrime.securesms.database.helpers.migration.V246_DropThumbnailCdnFromAttachments +import org.thoughtcrime.securesms.database.helpers.migration.V247_ClearUploadTimestamp /** * Contains all of the database migrations for [SignalDatabase]. Broken into a separate file for cleanliness. @@ -211,10 +212,11 @@ object SignalDatabaseMigrations { 243 to V243_MessageFullTextSearchDisableSecureDelete, 244 to V244_AttachmentRemoteIv, 245 to V245_DeletionTimestampOnCallLinks, - 246 to V246_DropThumbnailCdnFromAttachments + 246 to V246_DropThumbnailCdnFromAttachments, + 247 to V247_ClearUploadTimestamp ) - const val DATABASE_VERSION = 246 + const val DATABASE_VERSION = 247 @JvmStatic fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V247_ClearUploadTimestamp.kt b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V247_ClearUploadTimestamp.kt new file mode 100644 index 0000000000..1c68f482d4 --- /dev/null +++ b/app/src/main/java/org/thoughtcrime/securesms/database/helpers/migration/V247_ClearUploadTimestamp.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2023 Signal Messenger, LLC + * SPDX-License-Identifier: AGPL-3.0-only + */ + +package org.thoughtcrime.securesms.database.helpers.migration + +import android.app.Application +import net.zetetic.database.sqlcipher.SQLiteDatabase + +/** + * There was a bad interaction with the digest backfill job, where digests could be changed, and then already-uploaded attachments could be re-used + * but with a no-longer-matching digest. This migration set the upload timestamp to 1 for all uploaded attachments so that we don't re-use them. + */ +@Suppress("ClassName") +object V247_ClearUploadTimestamp : SignalDatabaseMigration { + override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { + db.execSQL("UPDATE attachment SET upload_timestamp = 1 WHERE upload_timestamp > 0") + } +}