mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-10 04:00:08 +08:00
Avoid using kotlin.time.Duration API in a binary-sensitive way, fix #1066
This commit is contained in:
parent
7867294f4d
commit
cedb239fc3
@ -272,7 +272,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
|
||||
bot.client.wLoginSigInfo.sKey.run {
|
||||
val delay = (expireTime - creationTime).seconds - 5.minutes
|
||||
logger.info { "Scheduled key refresh in ${delay.toHumanReadableString()}." }
|
||||
delay(delay)
|
||||
delay(delay.toLongMilliseconds()) // avoid delay(Duration) to keep binary compatibility
|
||||
}
|
||||
runCatching {
|
||||
refreshKeys()
|
||||
|
@ -33,7 +33,7 @@ internal class ScheduledJob(
|
||||
private val channel = Channel<Unit>(Channel.CONFLATED)
|
||||
|
||||
fun notice() {
|
||||
if (interval == Duration.ZERO) {
|
||||
if (interval.toLongMilliseconds() != 0L) { // Avoid Duration.ZERO for binary compatibility
|
||||
launch { task() }
|
||||
} else channel.offer(Unit)
|
||||
}
|
||||
@ -47,7 +47,7 @@ internal class ScheduledJob(
|
||||
}
|
||||
|
||||
init {
|
||||
if (interval != Duration.ZERO) {
|
||||
if (interval.toLongMilliseconds() != 0L) { // Avoid Duration.ZERO for binary compatibility
|
||||
launch {
|
||||
channel.receiveAsFlow()
|
||||
.runCatching {
|
||||
|
Loading…
Reference in New Issue
Block a user