Avoid using kotlin.time.Duration API in a binary-sensitive way, fix #1066

This commit is contained in:
Him188 2021-03-03 08:02:48 +08:00
parent 7867294f4d
commit cedb239fc3
2 changed files with 3 additions and 3 deletions

View File

@ -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()

View File

@ -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 {