mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-13 03:16:05 +08:00
Suppress false positive warning
This commit is contained in:
parent
52d6283af3
commit
f3e28fa664
@ -28,7 +28,6 @@ actual var DefaultCaptchaSolver: CaptchaSolver = {
|
|||||||
val tempFile: File = createTempFile(suffix = ".png").apply { deleteOnExit() }
|
val tempFile: File = createTempFile(suffix = ".png").apply { deleteOnExit() }
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
tempFile.createNewFile()
|
tempFile.createNewFile()
|
||||||
@Suppress("EXPERIMENTAL_API_USAGE")
|
|
||||||
MiraiLogger.info("需要验证码登录, 验证码为 4 字母")
|
MiraiLogger.info("需要验证码登录, 验证码为 4 字母")
|
||||||
try {
|
try {
|
||||||
tempFile.writeChannel().use { writeFully(it) }
|
tempFile.writeChannel().use { writeFully(it) }
|
||||||
@ -42,6 +41,7 @@ actual var DefaultCaptchaSolver: CaptchaSolver = {
|
|||||||
if (img == null) {
|
if (img == null) {
|
||||||
MiraiLogger.info("无法创建字符图片. 请查看文件")
|
MiraiLogger.info("无法创建字符图片. 请查看文件")
|
||||||
} else {
|
} else {
|
||||||
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
MiraiLogger.info(img.createCharImg())
|
MiraiLogger.info(img.createCharImg())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,6 +55,7 @@ actual var DefaultCaptchaSolver: CaptchaSolver = {
|
|||||||
private fun File.writeChannel(
|
private fun File.writeChannel(
|
||||||
coroutineContext: CoroutineContext = Dispatchers.IO
|
coroutineContext: CoroutineContext = Dispatchers.IO
|
||||||
): ByteWriteChannel = GlobalScope.reader(CoroutineName("file-writer") + coroutineContext, autoFlush = true) {
|
): ByteWriteChannel = GlobalScope.reader(CoroutineName("file-writer") + coroutineContext, autoFlush = true) {
|
||||||
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
RandomAccessFile(this@writeChannel, "rw").use { file ->
|
RandomAccessFile(this@writeChannel, "rw").use { file ->
|
||||||
val copied = channel.copyTo(file.channel)
|
val copied = channel.copyTo(file.channel)
|
||||||
file.setLength(copied) // truncate tail that could remain from the previously written data
|
file.setLength(copied) // truncate tail that could remain from the previously written data
|
||||||
|
Loading…
Reference in New Issue
Block a user