mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-01 01:44:34 -05:00
Deschedule previous task
This commit is contained in:
@@ -46,6 +46,8 @@ object SyncManager {
|
||||
private val syncPreferences = Injekt.get<Application>().getSharedPreferences("sync", Context.MODE_PRIVATE)
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
private var currentTaskId: String? = null
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
fun scheduleSyncTask() {
|
||||
serverConfig.subscribeTo(
|
||||
@@ -54,9 +56,11 @@ object SyncManager {
|
||||
serverConfig.syncInterval,
|
||||
) { enabled, interval -> Pair(enabled, interval) },
|
||||
{ (enabled, interval) ->
|
||||
if (enabled && interval > 0) {
|
||||
currentTaskId = if (enabled && interval > 0) {
|
||||
val intervalMs = interval.minutes.inWholeMilliseconds
|
||||
|
||||
currentTaskId?.let { HAScheduler.deschedule(it) }
|
||||
|
||||
HAScheduler.schedule(
|
||||
{
|
||||
GlobalScope.launch {
|
||||
@@ -67,6 +71,8 @@ object SyncManager {
|
||||
delay = intervalMs,
|
||||
name = "sync",
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
},
|
||||
ignoreInitialValue = false,
|
||||
|
||||
Reference in New Issue
Block a user