From 2452b03a49572b73a30bea0ea87cf576f864fe3f Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sat, 22 Jul 2023 01:52:12 +0200 Subject: [PATCH] Schedule automated update only once per hour (#605) The update was scheduled to run every minute of the set hour. But it should only run once in the set hour. --- .../suwayomi/tachidesk/manga/impl/update/Updater.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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 1a373a5bf..820e23dec 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 @@ -1,8 +1,6 @@ package suwayomi.tachidesk.manga.impl.update import eu.kanade.tachiyomi.source.model.UpdateStrategy -import it.sauronsoftware.cron4j.Task -import it.sauronsoftware.cron4j.TaskExecutionContext import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -26,7 +24,6 @@ import org.kodein.di.instance import suwayomi.tachidesk.manga.impl.Category import suwayomi.tachidesk.manga.impl.CategoryManga import suwayomi.tachidesk.manga.impl.Chapter -import suwayomi.tachidesk.manga.impl.backup.proto.ProtoBackupExport import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass import suwayomi.tachidesk.manga.model.dataclass.IncludeInUpdate import suwayomi.tachidesk.manga.model.dataclass.MangaDataClass @@ -34,8 +31,6 @@ import suwayomi.tachidesk.manga.model.table.MangaStatus import suwayomi.tachidesk.server.serverConfig import suwayomi.tachidesk.util.HAScheduler import java.util.Date -import java.util.Timer -import java.util.TimerTask import java.util.concurrent.ConcurrentHashMap import java.util.prefs.Preferences import kotlin.time.Duration.Companion.hours @@ -61,7 +56,6 @@ class Updater : IUpdater { scheduleUpdateTask() } - private fun autoUpdateTask() { val lastAutomatedUpdate = preferences.getLong(lastAutomatedUpdateKey, 0) preferences.putLong(lastAutomatedUpdateKey, System.currentTimeMillis()) @@ -94,7 +88,7 @@ class Updater : IUpdater { autoUpdateTask() } - HAScheduler.schedule(::autoUpdateTask, "* */${updateInterval.inWholeHours} * * *", "global-update") + HAScheduler.schedule(::autoUpdateTask, "0 */${updateInterval.inWholeHours} * * *", "global-update") } private fun getOrCreateUpdateChannelFor(source: String): Channel {