Skip to content

Commit

Permalink
feat: Retrieve the last uploaded transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
sirambd committed Oct 24, 2024
1 parent 779b0aa commit 7a53fb9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ class TransferManager internal constructor(
.flowOn(Dispatchers.IO)
}

/**
* Retrieves a transfer by linkUUID.
*
* @param transferUUID The UUID of an existing transfer in the database.
*
* @return A transfer matching the specified linkUUID or null.
*/
fun getTransferByLinkUUID(transferUUID: String): Transfer? {
return transferController.getTransfer(transferUUID)
}

/**
* Retrieves a transfer using the provided link UUID and saves it to the database.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ class UploadManager(
*
* @param uuid The UUID of the upload session.
*
* @return The transfer UUID of the uploaded transfer.
*
* @throws CancellationException If the operation is cancelled.
* @throws ApiException If there is a general API error.
* @throws UnexpectedApiErrorFormatException If the API error format is unexpected.
Expand All @@ -220,7 +222,7 @@ class UploadManager(
NotFoundException::class,
NullPropertyException::class,
)
suspend fun finishUploadSession(uuid: String): Unit = withContext(Dispatchers.IO) {
suspend fun finishUploadSession(uuid: String): String = withContext(Dispatchers.IO) {
val uploadSession = uploadController.getUploadByUUID(uuid)
?: throw NotFoundException("Unknown upload session with uuid = $uuid")
val containerUUID = uploadSession.remoteContainer?.uuid
Expand All @@ -238,5 +240,7 @@ class UploadManager(

transferManager.addTransferByLinkUUID(finishUploadResponse.linkUUID)
// TODO: If we can't retrieve the transfer cause of the Internet, we should put it in Realm and try again later.

return@withContext finishUploadResponse.linkUUID
}
}

0 comments on commit 7a53fb9

Please sign in to comment.