From f42cf7896995242745696260730f3b11594e1762 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 10 Aug 2021 16:50:50 +0600 Subject: [PATCH] fixes --- .../bot/Ktor/base/DownloadFileChannelRequestCallFactory.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/DownloadFileChannelRequestCallFactory.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/DownloadFileChannelRequestCallFactory.kt index eba7e7d4a1..3532ec5217 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/DownloadFileChannelRequestCallFactory.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/bot/Ktor/base/DownloadFileChannelRequestCallFactory.kt @@ -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(fullUrl).execute { httpResponse -> val channel: ByteReadChannel = httpResponse.receive() - channel.copyTo(outChannel) + channel.copyAndClose(outChannel) } } outChannel