Skip to content

Commit

Permalink
Schedule automated update only once per hour (#605)
Browse files Browse the repository at this point in the history
The update was scheduled to run every minute of the set hour.
But it should only run once in the set hour.
  • Loading branch information
schroda authored Jul 21, 2023
1 parent 2ce423b commit 2452b03
Showing 1 changed file with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -26,16 +24,13 @@ 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
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
Expand All @@ -61,7 +56,6 @@ class Updater : IUpdater {
scheduleUpdateTask()
}


private fun autoUpdateTask() {
val lastAutomatedUpdate = preferences.getLong(lastAutomatedUpdateKey, 0)
preferences.putLong(lastAutomatedUpdateKey, System.currentTimeMillis())
Expand Down Expand Up @@ -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<UpdateJob> {
Expand Down

0 comments on commit 2452b03

Please sign in to comment.