mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-10 14:24:34 -05:00
Use mathematical modulo implementation for calculations (#616)
See documentation (%/rem, mod) for differences. Example for "issue" that occurred: mathematical: -4 % 6 = 2 (expected) kotlin: -4 % 6 = -4 (unexpected)
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user