From 043948401dffc87828198ae17413ae0914753d02 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 11 Apr 2022 21:42:12 +0600 Subject: [PATCH] fixes in getting of content file cache --- .../media/common/DefaultMessageContentCache.kt | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/cache/content/common/src/commonMain/kotlin/dev/inmo/tgbotapi/libraries/cache/media/common/DefaultMessageContentCache.kt b/cache/content/common/src/commonMain/kotlin/dev/inmo/tgbotapi/libraries/cache/media/common/DefaultMessageContentCache.kt index 5a4e01c..71c6de5 100644 --- a/cache/content/common/src/commonMain/kotlin/dev/inmo/tgbotapi/libraries/cache/media/common/DefaultMessageContentCache.kt +++ b/cache/content/common/src/commonMain/kotlin/dev/inmo/tgbotapi/libraries/cache/media/common/DefaultMessageContentCache.kt @@ -10,7 +10,6 @@ import dev.inmo.tgbotapi.types.InputMedia.* import dev.inmo.tgbotapi.types.MessageIdentifier import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent -import dev.inmo.tgbotapi.utils.StorageFile import dev.inmo.tgbotapi.utils.asInput import io.ktor.utils.io.cancel import io.ktor.utils.io.core.Input @@ -66,20 +65,7 @@ class DefaultMessageContentCache( if (savedSimpleContent is MediaContent) { runCatching { - val streamAllocator = bot.execute( - DownloadFileStream( - bot.execute( - GetFile( - savedSimpleContent.media.fileId - ) - ).filePath - ) - ) - - streamAllocator().apply { - readByte() - cancel() - } + bot.execute(GetFile(savedSimpleContent.media.fileId)) }.onFailure { val savedFileContentAllocator = messagesFilesCache.get(chatId, messageId) ?: error("Unexpected absence of $chatId:$messageId file for content ($simpleMessageContentCache)") val newContent = bot.execute(