This commit is contained in:
InsanusMokrassar 2021-08-10 16:50:50 +06:00
parent 9a14932511
commit f42cf78969
1 changed files with 3 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.bot.Ktor.base
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
import dev.inmo.tgbotapi.bot.Ktor.KtorCallFactory
import dev.inmo.tgbotapi.requests.DownloadFileStream
import dev.inmo.tgbotapi.requests.abstracts.Request
@ -26,10 +27,10 @@ object DownloadFileChannelRequestCallFactory : KtorCallFactory {
ByteReadChannelAllocator {
val scope = CoroutineScope(coroutineContext)
val outChannel = ByteChannel()
scope.launch {
scope.launchSafelyWithoutExceptions {
client.get<HttpStatement>(fullUrl).execute { httpResponse ->
val channel: ByteReadChannel = httpResponse.receive()
channel.copyTo(outChannel)
channel.copyAndClose(outChannel)
}
}
outChannel