From 6ada1d1ddbc5dce34c0d08523d5326a51d68e56f Mon Sep 17 00:00:00 2001 From: Abdourahamane Boinaidi Date: Thu, 31 Oct 2024 09:33:17 +0100 Subject: [PATCH] fix: Make track upload as suspend callback --- .../multiplatform_swisstransfer/managers/UploadManager.kt | 2 +- .../network/repositories/UploadRepository.kt | 2 +- .../network/requests/UploadRequest.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/UploadManager.kt b/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/UploadManager.kt index 1ae938e4..c3f0eb16 100644 --- a/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/UploadManager.kt +++ b/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/managers/UploadManager.kt @@ -181,7 +181,7 @@ class UploadManager( chunkIndex: Int, isLastChunk: Boolean, data: ByteArray, - onUpload: (bytesSentTotal: Long, chunkSize: Long) -> Unit, + onUpload: suspend (bytesSentTotal: Long, chunkSize: Long) -> Unit, ): Unit = withContext(Dispatchers.IO) { val uploadSession = uploadController.getUploadByUUID(uuid) ?: throw NotFoundException("${UploadSession::class.simpleName} not found in DB with uuid = $uuid") diff --git a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/repositories/UploadRepository.kt b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/repositories/UploadRepository.kt index 1616d526..05b591d2 100644 --- a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/repositories/UploadRepository.kt +++ b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/repositories/UploadRepository.kt @@ -110,7 +110,7 @@ class UploadRepository internal constructor(private val uploadRequest: UploadReq chunkIndex: Int, isLastChunk: Boolean, data: ByteArray, - onUpload: (bytesSentTotal: Long, chunkSize: Long) -> Unit, + onUpload: suspend (bytesSentTotal: Long, chunkSize: Long) -> Unit, ): Boolean { return uploadRequest.uploadChunk(uploadHost, containerUUID, fileUUID, chunkIndex, isLastChunk, data, onUpload) } diff --git a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/UploadRequest.kt b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/UploadRequest.kt index 75a0e280..3b89844a 100644 --- a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/UploadRequest.kt +++ b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/UploadRequest.kt @@ -58,7 +58,7 @@ internal class UploadRequest(json: Json, httpClient: HttpClient) : BaseRequest(j chunkIndex: Int, isLastChunk: Boolean, data: ByteArray, - onUpload: (bytesSentTotal: Long, chunkSize: Long) -> Unit, + onUpload: suspend (bytesSentTotal: Long, chunkSize: Long) -> Unit, ): Boolean { val httpResponse = httpClient.post( urlString = SharedApiRoutes.uploadChunk(uploadHost, containerUUID, fileUUID, chunkIndex, isLastChunk)