Remove archive_transfer_file column.

This commit is contained in:
Greyson Parrelli
2025-06-24 09:28:44 -04:00
committed by Cody Henthorne
parent 03dc014c08
commit b1063f69f9
5 changed files with 27 additions and 44 deletions

View File

@@ -216,7 +216,6 @@ class AttachmentTable(
DATA_HASH_START,
DATA_HASH_END,
ARCHIVE_CDN,
ARCHIVE_TRANSFER_FILE,
THUMBNAIL_FILE,
THUMBNAIL_RESTORE_STATE,
ARCHIVE_TRANSFER_STATE,
@@ -260,7 +259,6 @@ class AttachmentTable(
$DATA_HASH_START TEXT DEFAULT NULL,
$DATA_HASH_END TEXT DEFAULT NULL,
$ARCHIVE_CDN INTEGER DEFAULT NULL,
$ARCHIVE_TRANSFER_FILE TEXT DEFAULT NULL,
$ARCHIVE_TRANSFER_STATE INTEGER DEFAULT ${ArchiveTransferState.NONE.value},
$THUMBNAIL_FILE TEXT DEFAULT NULL,
$THUMBNAIL_RANDOM BLOB DEFAULT NULL,
@@ -1203,7 +1201,6 @@ class AttachmentTable(
values.put(TRANSFER_STATE, TRANSFER_PROGRESS_DONE)
values.put(TRANSFER_FILE, null as String?)
values.put(TRANSFORM_PROPERTIES, TransformProperties.forSkipTransform().serialize())
values.put(ARCHIVE_TRANSFER_FILE, null as String?)
values.put(REMOTE_LOCATION, existingPlaceholder.remoteLocation)
values.put(CDN_NUMBER, existingPlaceholder.cdn.serialize())
values.put(REMOTE_KEY, existingPlaceholder.remoteKey!!)
@@ -1624,24 +1621,6 @@ class AttachmentTable(
return transferFile
}
@Throws(IOException::class)
fun getOrCreateArchiveTransferFile(attachmentId: AttachmentId): File {
val existing = getArchiveTransferFile(writableDatabase, attachmentId)
if (existing != null) {
return existing
}
val transferFile = newTransferFile()
writableDatabase
.update(TABLE_NAME)
.values(ARCHIVE_TRANSFER_FILE to transferFile.absolutePath)
.where("$ID = ?", attachmentId.id)
.run()
return transferFile
}
fun createArchiveThumbnailTransferFile(): File {
return newTransferFile()
}
@@ -2455,18 +2434,6 @@ class AttachmentTable(
}
}
private fun getArchiveTransferFile(db: SQLiteDatabase, attachmentId: AttachmentId): File? {
return db
.select(ARCHIVE_TRANSFER_FILE)
.from(TABLE_NAME)
.where("$ID = ?", attachmentId.id)
.limit(1)
.run()
.readToSingleObject { cursor ->
cursor.requireString(ARCHIVE_TRANSFER_FILE)?.let { File(it) }
}
}
private fun getAttachment(cursor: Cursor): DatabaseAttachment {
val contentType = cursor.requireString(CONTENT_TYPE)

View File

@@ -135,6 +135,7 @@ import org.thoughtcrime.securesms.database.helpers.migration.V277_AddNotificatio
import org.thoughtcrime.securesms.database.helpers.migration.V278_BackupSnapshotTableVersions
import org.thoughtcrime.securesms.database.helpers.migration.V279_AddNotificationProfileForeignKey
import org.thoughtcrime.securesms.database.helpers.migration.V280_RemoveAttachmentIv
import org.thoughtcrime.securesms.database.helpers.migration.V281_RemoveArchiveTransferFile
import org.thoughtcrime.securesms.database.SQLiteDatabase as SignalSqliteDatabase
/**
@@ -275,10 +276,11 @@ object SignalDatabaseMigrations {
277 to V277_AddNotificationProfileStorageSync,
278 to V278_BackupSnapshotTableVersions,
279 to V279_AddNotificationProfileForeignKey,
280 to V280_RemoveAttachmentIv
280 to V280_RemoveAttachmentIv,
281 to V281_RemoveArchiveTransferFile
)
const val DATABASE_VERSION = 280
const val DATABASE_VERSION = 281
@JvmStatic
fun migrate(context: Application, db: SignalSqliteDatabase, oldVersion: Int, newVersion: Int) {

View File

@@ -0,0 +1,19 @@
/*
* 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
/**
* We used to decrypt archive files in two distinct steps, and therefore needed a secondary transfer file.
* Now, we're able to do all of the decrypt in one stream, so we no longer need the intermediary transfer file.
*/
object V281_RemoveArchiveTransferFile : SignalDatabaseMigration {
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
db.execSQL("ALTER TABLE attachment DROP COLUMN archive_transfer_file")
}
}