|
1 | 1 | /*
|
2 | 2 | * Infomaniak Mail - Android
|
3 |
| - * Copyright (C) 2023-2024 Infomaniak Network SA |
| 3 | + * Copyright (C) 2023-2025 Infomaniak Network SA |
4 | 4 | *
|
5 | 5 | * This program is free software: you can redistribute it and/or modify
|
6 | 6 | * it under the terms of the GNU General Public License as published by
|
@@ -45,6 +45,8 @@ import com.infomaniak.mail.utils.WorkerUtils.UploadMissingLocalFileException
|
45 | 45 | import com.infomaniak.mail.utils.extensions.AttachmentExtensions.AttachmentIntentType.OPEN_WITH
|
46 | 46 | import com.infomaniak.mail.utils.extensions.AttachmentExtensions.AttachmentIntentType.SAVE_TO_DRIVE
|
47 | 47 | import io.realm.kotlin.Realm
|
| 48 | +import kotlinx.coroutines.NonCancellable |
| 49 | +import kotlinx.coroutines.withContext |
48 | 50 | import okhttp3.MediaType.Companion.toMediaType
|
49 | 51 | import okhttp3.Request
|
50 | 52 | import okhttp3.RequestBody.Companion.asRequestBody
|
@@ -155,7 +157,9 @@ object AttachmentExtensions {
|
155 | 157 |
|
156 | 158 | val apiResponse = ApiController.json.decodeFromString<ApiResponse<Attachment>>(response.body?.string() ?: "")
|
157 | 159 | if (apiResponse.isSuccess() && apiResponse.data != null) {
|
158 |
| - updateLocalAttachment(draftLocalUuid, apiResponse.data!!, draftController, realm) |
| 160 | + withContext(NonCancellable) { |
| 161 | + updateLocalAttachment(draftLocalUuid, apiResponse.data!!, draftController, realm) |
| 162 | + } |
159 | 163 | } else {
|
160 | 164 | val baseMessage = "Upload failed for attachment $localUuid"
|
161 | 165 | val errorMessage = "error : ${apiResponse.translatedError}"
|
|
0 commit comments