diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/Updater.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/Updater.kt index ecd754bc..3a526d0a 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/Updater.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/Updater.kt @@ -75,7 +75,7 @@ class Updater : IUpdater { val updateInterval = serverConfig.globalUpdateInterval.hours.coerceAtLeast(6.hours).inWholeMilliseconds val lastAutomatedUpdate = preferences.getLong(lastAutomatedUpdateKey, 0) - val timeToNextExecution = updateInterval - (System.currentTimeMillis() - lastAutomatedUpdate) % updateInterval + val timeToNextExecution = (updateInterval - (System.currentTimeMillis() - lastAutomatedUpdate)).mod(updateInterval) val wasPreviousUpdateTriggered = System.currentTimeMillis() - (if (lastAutomatedUpdate > 0) lastAutomatedUpdate else System.currentTimeMillis()) < updateInterval if (!wasPreviousUpdateTriggered) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/util/HAScheduler.kt b/server/src/main/kotlin/suwayomi/tachidesk/util/HAScheduler.kt index 6ce4616c..966bae2a 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/util/HAScheduler.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/util/HAScheduler.kt @@ -62,7 +62,7 @@ class HATask(id: String, val interval: Long, execute: () -> Unit, val timerTask: private fun getElapsedTimeOfCurrentInterval(): Long { val timeSinceFirstExecution = System.currentTimeMillis() - firstExecutionTime - return timeSinceFirstExecution % interval + return timeSinceFirstExecution.mod(interval) } override fun getLastExecutionTime(): Long {