Skip to content

Commit

Permalink
fix: correctly close stream
Browse files Browse the repository at this point in the history
  • Loading branch information
Samarium150 committed Dec 21, 2021
1 parent aca755e commit f88e4bb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {
}

group = "io.github.samarium150"
version = "5.0.0-beta.4"
version = "5.0.0-beta.5"

repositories {
mavenLocal()
Expand Down Expand Up @@ -44,8 +44,8 @@ tasks.withType<DokkaTask>().configureEach {
}
jdkVersion.set(11)
externalDocumentationLink {
url.set(URL("https://kdoc.mirai.mamoe.net/2.9.0-RC"))
packageListUrl.set(URL("https://kdoc.mirai.mamoe.net/2.9.0-RC/package-list"))
url.set(URL("https://kdoc.mirai.mamoe.net/2.9.0-RC2"))
packageListUrl.set(URL("https://kdoc.mirai.mamoe.net/2.9.0-RC2/package-list"))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import java.net.Proxy
object MiraiConsoleLolicon : KotlinPlugin(
JvmPluginDescription(
id = "io.github.samarium150.mirai.plugin.mirai-console-lolicon",
version = "5.0.0-beta.4",
version = "5.0.0-beta.5",
name = "Lolicon"
) {
author("Samarium150")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import io.github.samarium150.mirai.plugin.config.ReplyConfig
import io.github.samarium150.mirai.plugin.data.PluginData
import io.github.samarium150.mirai.plugin.data.RequestBody
import io.github.samarium150.mirai.plugin.util.CooldownUtil
import io.github.samarium150.mirai.plugin.util.ThrottleUtil
import io.github.samarium150.mirai.plugin.util.GeneralUtil
import io.github.samarium150.mirai.plugin.util.ThrottleUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
Expand Down Expand Up @@ -105,6 +107,7 @@ object Lolicon : CompositeCommand(
val imageData = response.data[0]
if (!GeneralUtil.areTagsAllowed(imageData.tags)) {
sendMessage(ReplyConfig.filteredTag)
ThrottleUtil.unlock(subject)
return
}
val url = imageData.urls[PluginConfig.size]
Expand Down Expand Up @@ -133,8 +136,7 @@ object Lolicon : CompositeCommand(
logger.error(e)
sendMessage(ReplyConfig.networkError)
} finally {
@Suppress("BlockingMethodInNonBlockingContext")
stream?.close()
withContext(Dispatchers.IO) { stream?.close() }
if (PluginConfig.verbose && imgInfoReceipt != null && recall > 0 && PluginConfig.recallImgInfo)
GeneralUtil.recall(GeneralUtil.RecallType.IMAGE_INFO, imgInfoReceipt, recall)
}
Expand Down Expand Up @@ -210,8 +212,7 @@ object Lolicon : CompositeCommand(
logger.error(e)
sendMessage(ReplyConfig.networkError)
} finally {
@Suppress("BlockingMethodInNonBlockingContext")
stream?.close()
withContext(Dispatchers.IO) { stream?.close() }
}
}
val imgInfoReceipt =
Expand Down

0 comments on commit f88e4bb

Please sign in to comment.