Another attempt to fix validation errors around invalid long text attachments.

This commit is contained in:
Greyson Parrelli
2025-09-08 16:18:11 -04:00
parent 49417bdf9d
commit 6108b5ab77
2 changed files with 6 additions and 3 deletions

View File

@@ -175,7 +175,7 @@ object ExportOddities {
}
fun unreadableLongTextAttachment(sentTimestamp: Long): String {
return log(sentTimestamp, "Long text attachment was unreadable. Falling back to the known body with an attachment pointer.")
return log(sentTimestamp, "Long text attachment was unreadable. Dropping the pointer.")
}
fun unopenableLongTextAttachment(sentTimestamp: Long): String {

View File

@@ -1041,7 +1041,9 @@ private fun BackupMessageRecord.getBodyText(attachments: List<DatabaseAttachment
}
if (longTextAttachment.uri == null || longTextAttachment.transferState != AttachmentTable.TRANSFER_PROGRESS_DONE) {
return StringUtil.trimToFit(this.body.emptyIfNull(), MAX_INLINED_BODY_SIZE_WITH_LONG_ATTACHMENT_POINTER) to longTextAttachment
Log.w(TAG, ExportOddities.undownloadedLongTextAttachment(this.dateSent))
val body = StringUtil.trimToFit(this.body.emptyIfNull(), MAX_INLINED_BODY_SIZE_WITH_LONG_ATTACHMENT_POINTER)
return body to longTextAttachment.takeUnless { body.isBlank() }
}
val longText = try {
@@ -1053,7 +1055,8 @@ private fun BackupMessageRecord.getBodyText(attachments: List<DatabaseAttachment
if (longText == null) {
Log.w(TAG, ExportOddities.unopenableLongTextAttachment(this.dateSent))
return StringUtil.trimToFit(this.body.emptyIfNull(), MAX_INLINED_BODY_SIZE_WITH_LONG_ATTACHMENT_POINTER) to longTextAttachment
val body = StringUtil.trimToFit(this.body.emptyIfNull(), MAX_INLINED_BODY_SIZE_WITH_LONG_ATTACHMENT_POINTER)
return body to longTextAttachment.takeUnless { body.isBlank() }
}
val trimmed = StringUtil.trimToFit(longText, MAX_INLINED_BODY_SIZE)