mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-20 19:18:37 +00:00
Fix edited message attachments stuck in download state.
This commit is contained in:
@@ -1655,20 +1655,32 @@ class AttachmentTable(
|
|||||||
|
|
||||||
val dataFilePath = hashMatch?.file?.absolutePath ?: fileWriteResult.file.absolutePath
|
val dataFilePath = hashMatch?.file?.absolutePath ?: fileWriteResult.file.absolutePath
|
||||||
|
|
||||||
if (archiveRestore && existingPlaceholder.dataHash != null) {
|
val updateCount = if (archiveRestore && existingPlaceholder.dataHash != null) {
|
||||||
// Can update all rows with the same mediaName as data_file column will likely be null
|
// Can update all rows with the same mediaName as data_file column will likely be null
|
||||||
db.update(TABLE_NAME)
|
db.update(TABLE_NAME)
|
||||||
.values(values)
|
.values(values)
|
||||||
.where("$ID = ? OR ($REMOTE_KEY = ? AND $DATA_HASH_END = ?)", attachmentId.id, existingPlaceholder.remoteKey, existingPlaceholder.dataHash!!)
|
.where("$ID = ? OR ($REMOTE_KEY = ? AND $DATA_HASH_END = ?)", attachmentId.id, existingPlaceholder.remoteKey, existingPlaceholder.dataHash!!)
|
||||||
.run()
|
.run()
|
||||||
} else {
|
} else {
|
||||||
|
// Update the current attachment, any attachments with the same data file (deduplication), and any attachments with the
|
||||||
|
// same UUID (e.g. edited messages)
|
||||||
|
val whereClause: String
|
||||||
|
val whereArgs: Array<String>
|
||||||
|
if (existingPlaceholder.uuid != null) {
|
||||||
|
whereClause = "$ID = ? OR $DATA_FILE = ? OR ($ATTACHMENT_UUID = ? AND $REMOTE_LOCATION = ?)"
|
||||||
|
whereArgs = SqlUtil.buildArgs(attachmentId.id, dataFilePath, existingPlaceholder.uuid.toString(), existingPlaceholder.remoteLocation)
|
||||||
|
} else {
|
||||||
|
whereClause = "$ID = ? OR $DATA_FILE = ?"
|
||||||
|
whereArgs = SqlUtil.buildArgs(attachmentId.id, dataFilePath)
|
||||||
|
}
|
||||||
|
|
||||||
db.update(TABLE_NAME)
|
db.update(TABLE_NAME)
|
||||||
.values(values)
|
.values(values)
|
||||||
.where("$ID = ? OR $DATA_FILE = ?", attachmentId.id, dataFilePath)
|
.where(whereClause, whereArgs)
|
||||||
.run()
|
.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i(TAG, "[finalizeAttachmentAfterDownload] Finalized downloaded data for $attachmentId. (MessageId: $mmsId, $attachmentId)")
|
Log.i(TAG, "[finalizeAttachmentAfterDownload] Updated $updateCount attachment row(s) for $attachmentId. (MessageId: $mmsId)")
|
||||||
|
|
||||||
hashMatch != null
|
hashMatch != null
|
||||||
}
|
}
|
||||||
@@ -2675,6 +2687,7 @@ class AttachmentTable(
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaUtil.isVideoType(contentType) -> {
|
MediaUtil.isVideoType(contentType) -> {
|
||||||
val videoThumbnail = MediaUtil.getVideoThumbnail(context, uri.uri)
|
val videoThumbnail = MediaUtil.getVideoThumbnail(context, uri.uri)
|
||||||
if (videoThumbnail != null) {
|
if (videoThumbnail != null) {
|
||||||
@@ -2691,6 +2704,7 @@ class AttachmentTable(
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
Log.w(TAG, "[generateQuoteThumbnail] Unsupported content type for thumbnail generation: $contentType")
|
Log.w(TAG, "[generateQuoteThumbnail] Unsupported content type for thumbnail generation: $contentType")
|
||||||
null
|
null
|
||||||
@@ -3137,6 +3151,7 @@ class AttachmentTable(
|
|||||||
${MessageTable.TABLE_NAME}.${MessageTable.VIEW_ONCE} = 0
|
${MessageTable.TABLE_NAME}.${MessageTable.VIEW_ONCE} = 0
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAttachment(cursor: Cursor): DatabaseAttachment {
|
private fun getAttachment(cursor: Cursor): DatabaseAttachment {
|
||||||
val contentType = cursor.requireString(CONTENT_TYPE)
|
val contentType = cursor.requireString(CONTENT_TYPE)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user