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 4d23649519..e4dcc8cf23 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 @@ -100,10 +100,6 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter val sessionComponent = getSessionComponent(params.sessionId) ?: return Result.success() sessionComponent.inject(this) - val attachment = params.attachment - - var newImageAttributes: NewImageAttributes? = null - val allCancelled = params.events.all { cancelSendTracker.isCancelRequestedFor(it.eventId, it.roomId) } if (allCancelled) { // there is no point in uploading the image! @@ -111,6 +107,7 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter .also { Timber.e("## Send: Work cancelled by user") } } + val attachment = params.attachment val filesToDelete = mutableListOf() try { @@ -181,6 +178,7 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter return try { val fileToUpload: File + var newImageAttributes: NewImageAttributes? = null if (attachment.type == ContentAttachmentData.Type.IMAGE && params.compressBeforeSending) { fileToUpload = imageCompressor.compress(context, workingFile, MAX_IMAGE_SIZE, MAX_IMAGE_SIZE)