Commit 0d089563 authored by Him188's avatar Him188

Add timeout check for uploading image

parent e2905635
......@@ -10,6 +10,7 @@
package net.mamoe.mirai.qqandroid
import kotlinx.coroutines.launch
import kotlinx.coroutines.withTimeoutOrNull
import kotlinx.io.core.Closeable
import net.mamoe.mirai.contact.*
import net.mamoe.mirai.data.*
......@@ -601,6 +602,8 @@ internal class GroupImpl(
).also { ImageUploadEvent.Succeed(this@GroupImpl, image, it).broadcast() }
}
is ImgStore.GroupPicUp.Response.RequireUpload -> {
// 每 100KB 等 1 秒
withTimeoutOrNull(image.inputSize / 1024 / 100) {
HighwayHelper.uploadImage(
client = bot.client,
serverIp = response.uploadIpList.first().toIpV4AddressString(),
......@@ -611,6 +614,7 @@ internal class GroupImpl(
uKey = response.uKey,
commandId = 2
)
} ?: error("timeout uploading image: ${image.filename}")
val resourceId = image.calculateImageResourceId()
// return NotOnlineImageFromFile(
// resourceId = resourceId,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment