mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-23 19:26:17 +00:00
Fix issue with attachments failing to download.
This commit is contained in:
@@ -253,6 +253,15 @@ class AttachmentTableTest_deduping {
|
||||
|
||||
assertDoesNotHaveRemoteFields(id2)
|
||||
assertArchiveFieldsMatch(id1, id2)
|
||||
|
||||
upload(id2)
|
||||
|
||||
assertDataFilesAreTheSame(id1, id2)
|
||||
assertDataHashStartMatches(id1, id2)
|
||||
assertDataHashEndMatches(id1, id2)
|
||||
assertSkipTransform(id1, true)
|
||||
assertSkipTransform(id2, true)
|
||||
assertRemoteFieldsMatch(id1, id2)
|
||||
}
|
||||
|
||||
// This isn't so much "desirable behavior" as it is documenting how things work.
|
||||
@@ -653,6 +662,7 @@ class AttachmentTableTest_deduping {
|
||||
}
|
||||
|
||||
fun upload(attachmentId: AttachmentId, uploadTimestamp: Long = System.currentTimeMillis()) {
|
||||
SignalDatabase.attachments.createKeyIvIfNecessary(attachmentId)
|
||||
SignalDatabase.attachments.finalizeAttachmentAfterUpload(attachmentId, createUploadResult(attachmentId, uploadTimestamp))
|
||||
|
||||
val attachment = SignalDatabase.attachments.getAttachment(attachmentId)!!
|
||||
|
||||
@@ -1250,6 +1250,8 @@ class AttachmentTable(
|
||||
TRANSFER_STATE to TRANSFER_PROGRESS_DONE,
|
||||
CDN_NUMBER to uploadResult.cdnNumber,
|
||||
REMOTE_LOCATION to uploadResult.remoteId.toString(),
|
||||
REMOTE_KEY to Base64.encodeWithPadding(uploadResult.key),
|
||||
REMOTE_IV to uploadResult.iv,
|
||||
REMOTE_DIGEST to uploadResult.digest,
|
||||
REMOTE_INCREMENTAL_DIGEST to uploadResult.incrementalDigest,
|
||||
REMOTE_INCREMENTAL_DIGEST_CHUNK_SIZE to uploadResult.incrementalDigestChunkSize,
|
||||
|
||||
@@ -106,8 +106,9 @@ import org.thoughtcrime.securesms.database.helpers.migration.V244_AttachmentRemo
|
||||
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
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V248_ArchiveTransferStateIndex
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V249_AttachmentOffloadRestoredAtColumn
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V250_ClearUploadTimestampV2
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V251_ArchiveTransferStateIndex
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V252_AttachmentOffloadRestoredAtColumn
|
||||
|
||||
/**
|
||||
* Contains all of the database migrations for [SignalDatabase]. Broken into a separate file for cleanliness.
|
||||
@@ -216,11 +217,13 @@ object SignalDatabaseMigrations {
|
||||
245 to V245_DeletionTimestampOnCallLinks,
|
||||
246 to V246_DropThumbnailCdnFromAttachments,
|
||||
247 to V247_ClearUploadTimestamp,
|
||||
248 to V248_ArchiveTransferStateIndex,
|
||||
249 to V249_AttachmentOffloadRestoredAtColumn
|
||||
// 248 and 249 were originally in 7.18.0, but are now skipped because we needed to hotfix 7.17.6 after 7.18.0 was already released.
|
||||
250 to V250_ClearUploadTimestampV2,
|
||||
251 to V251_ArchiveTransferStateIndex,
|
||||
252 to V252_AttachmentOffloadRestoredAtColumn
|
||||
)
|
||||
|
||||
const val DATABASE_VERSION = 249
|
||||
const val DATABASE_VERSION = 252
|
||||
|
||||
@JvmStatic
|
||||
fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
/**
|
||||
* Turns out we need to run [V247_ClearUploadTimestamp] again, because there was another situation where we had mismatching transit data across duplicates.
|
||||
*/
|
||||
@Suppress("ClassName")
|
||||
object V250_ClearUploadTimestampV2 : SignalDatabaseMigration {
|
||||
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
db.execSQL("UPDATE attachment SET upload_timestamp = 1 WHERE upload_timestamp > 0")
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,11 @@ import net.zetetic.database.sqlcipher.SQLiteDatabase
|
||||
|
||||
/**
|
||||
* Adds an index to improve the perf of counting and filtering attachment rows by their transfer state.
|
||||
*
|
||||
* Important: May be ran twice depending on people's upgrade path during the beta.
|
||||
*/
|
||||
@Suppress("ClassName")
|
||||
object V248_ArchiveTransferStateIndex : SignalDatabaseMigration {
|
||||
object V251_ArchiveTransferStateIndex : SignalDatabaseMigration {
|
||||
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
db.execSQL("CREATE INDEX IF NOT EXISTS attachment_archive_transfer_state ON attachment (archive_transfer_state)")
|
||||
}
|
||||
@@ -7,13 +7,25 @@ package org.thoughtcrime.securesms.database.helpers.migration
|
||||
|
||||
import android.app.Application
|
||||
import net.zetetic.database.sqlcipher.SQLiteDatabase
|
||||
import org.signal.core.util.SqlUtil
|
||||
import org.signal.core.util.logging.Log
|
||||
|
||||
/**
|
||||
* Adds the offload_restored_at column to attachments.
|
||||
*
|
||||
* Important: May be ran twice depending on people's upgrade path during the beta.
|
||||
*/
|
||||
@Suppress("ClassName")
|
||||
object V249_AttachmentOffloadRestoredAtColumn : SignalDatabaseMigration {
|
||||
object V252_AttachmentOffloadRestoredAtColumn : SignalDatabaseMigration {
|
||||
|
||||
private val TAG = Log.tag(V252_AttachmentOffloadRestoredAtColumn::class)
|
||||
|
||||
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
if (SqlUtil.columnExists(db, "attachment", "offload_restored_at")) {
|
||||
Log.i(TAG, "Already ran migration!")
|
||||
return
|
||||
}
|
||||
|
||||
db.execSQL("ALTER TABLE attachment ADD COLUMN offload_restored_at INTEGER DEFAULT 0;")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user