From 04b02877388ae9b243ce3dfd62a61b6e543af152 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 29 Mar 2020 12:41:07 +0800 Subject: [PATCH] Add pre-condition check --- .../jvmMain/kotlin/net/mamoe/mirai/message/SendImageUtilsJvm.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/SendImageUtilsJvm.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/SendImageUtilsJvm.kt index f045ac98f..31bfecdeb 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/SendImageUtilsJvm.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/message/SendImageUtilsJvm.kt @@ -116,7 +116,7 @@ suspend fun InputStream.uploadAsImage(contact: Contact): OfflineImage = */ @Throws(OverFileSizeMaxException::class) suspend fun File.uploadAsImage(contact: Contact): OfflineImage { - require(this.exists() && this.canRead()) + require(this.isFile && this.exists() && this.canRead()) { "file ${this.path} is not readable" } return withContext(Dispatchers.IO) { toExternalImage() }.upload(contact) }