From 0d3727f08b029232a97d02031bb970cb0a88a473 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Thu, 4 Sep 2025 12:18:49 -0400 Subject: [PATCH] Handle thumbnail generation failing more gracefully. --- .../jobs/ArchiveThumbnailUploadJob.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/ArchiveThumbnailUploadJob.kt b/app/src/main/java/org/thoughtcrime/securesms/jobs/ArchiveThumbnailUploadJob.kt index cee9cc1300..d6869bcc3a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/ArchiveThumbnailUploadJob.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/ArchiveThumbnailUploadJob.kt @@ -253,16 +253,21 @@ class ArchiveThumbnailUploadJob private constructor( } private fun generateThumbnailIfPossible(attachment: DatabaseAttachment): ImageCompressionUtil.Result? { - val uri: DecryptableUri = attachment.uri?.let { DecryptableUri(it) } ?: return null + try { + val uri: DecryptableUri = attachment.uri?.let { DecryptableUri(it) } ?: return null - return if (MediaUtil.isImageType(attachment.contentType)) { - compress(uri, attachment.contentType ?: "") - } else if (Build.VERSION.SDK_INT >= 23 && MediaUtil.isVideoType(attachment.contentType)) { - MediaUtil.getVideoThumbnail(context, attachment.uri)?.let { + return if (MediaUtil.isImageType(attachment.contentType)) { compress(uri, attachment.contentType ?: "") + } else if (Build.VERSION.SDK_INT >= 23 && MediaUtil.isVideoType(attachment.contentType)) { + MediaUtil.getVideoThumbnail(context, attachment.uri)?.let { + compress(uri, attachment.contentType ?: "") + } + } else { + null } - } else { - null + } catch (e: Exception) { + Log.w(TAG, "Failed to generate thumbnail for $attachmentId", e) + return null } }