Fix old RemoteFile uploading logic

This commit is contained in:
Karlatemp 2021-11-16 18:21:55 +08:00
parent cf2b4a193c
commit 79d92a0114
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8

View File

@ -528,14 +528,23 @@ internal class RemoteFileImpl(
return resp
}
private suspend fun uploadInternal(
resource: ExternalResource,
callback: RemoteFile.ProgressionCallback?,
): FileMessage {
val resp = upload0(resource, callback) ?: error("Failed to upload file.")
return FileMessageImpl(
resp.fileId, resp.busId, name, resource.size
)
}
override suspend fun upload(
resource: ExternalResource,
callback: RemoteFile.ProgressionCallback?,
): FileMessage {
val resp = upload0(resource, null) ?: error("Failed to upload file.")
return FileMessageImpl(
resp.fileId, resp.busId, name, resource.size
)
val msg = uploadInternal(resource, callback)
contact.sendMessage(msg + MiraiInternalMessageFlag)
return msg
}
// compiler bug
@ -560,7 +569,7 @@ internal class RemoteFileImpl(
override suspend fun uploadAndSend(resource: ExternalResource): MessageReceipt<Contact> {
@Suppress("DEPRECATION")
return contact.sendMessage(upload(resource) + MiraiInternalMessageFlag)
return contact.sendMessage(uploadInternal(resource, null) + MiraiInternalMessageFlag)
}
// compiler bug