From f3e28fa664dcd85441489c9948bd9c9717ab8331 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 8 Dec 2019 21:14:08 +0800 Subject: [PATCH] Suppress false positive warning --- .../kotlin/net/mamoe/mirai/utils/DefaultCaptchaSolverJvm.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/DefaultCaptchaSolverJvm.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/DefaultCaptchaSolverJvm.kt index d5e88bbfd..5ac5ccc88 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/DefaultCaptchaSolverJvm.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/DefaultCaptchaSolverJvm.kt @@ -28,7 +28,6 @@ actual var DefaultCaptchaSolver: CaptchaSolver = { val tempFile: File = createTempFile(suffix = ".png").apply { deleteOnExit() } withContext(Dispatchers.IO) { tempFile.createNewFile() - @Suppress("EXPERIMENTAL_API_USAGE") MiraiLogger.info("需要验证码登录, 验证码为 4 字母") try { tempFile.writeChannel().use { writeFully(it) } @@ -42,6 +41,7 @@ actual var DefaultCaptchaSolver: CaptchaSolver = { if (img == null) { MiraiLogger.info("无法创建字符图片. 请查看文件") } else { + @Suppress("BlockingMethodInNonBlockingContext") MiraiLogger.info(img.createCharImg()) } } @@ -55,6 +55,7 @@ actual var DefaultCaptchaSolver: CaptchaSolver = { private fun File.writeChannel( coroutineContext: CoroutineContext = Dispatchers.IO ): ByteWriteChannel = GlobalScope.reader(CoroutineName("file-writer") + coroutineContext, autoFlush = true) { + @Suppress("BlockingMethodInNonBlockingContext") RandomAccessFile(this@writeChannel, "rw").use { file -> val copied = channel.copyTo(file.channel) file.setLength(copied) // truncate tail that could remain from the previously written data