From bdf9402685d419091159ba707aabc8010357c897 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 23 Nov 2021 17:45:10 +0000 Subject: [PATCH] only deleting voice files if they were successfully uploading - fixes flaky networks losing the voice file and being unable to retry --- .../internal/session/content/UploadContentWorker.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt index b657d950bd..86e0630fcf 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt @@ -279,6 +279,11 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter Timber.e(failure, "## Failed to update file cache") } + // Delete the temporary voice message file + if (params.attachment.type == ContentAttachmentData.Type.AUDIO && params.attachment.mimeType == MimeTypes.Ogg) { + context.contentResolver.delete(params.attachment.queryUri, null, null) + } + val uploadThumbnailResult = dealWithThumbnail(params) handleSuccess(params, @@ -299,11 +304,6 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter filesToDelete.forEach { tryOrNull { it.delete() } } - - // Delete the temporary voice message file - if (params.attachment.type == ContentAttachmentData.Type.AUDIO && params.attachment.mimeType == MimeTypes.Ogg) { - context.contentResolver.delete(params.attachment.queryUri, null, null) - } } }