diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt index 70c91104..e8e56cd1 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt @@ -10,7 +10,11 @@ package suwayomi.tachidesk.manga.impl.backup.proto import android.app.Application import android.content.Context import eu.kanade.tachiyomi.source.model.UpdateStrategy +import kotlinx.coroutines.DelicateCoroutinesApi +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.launch import mu.KotlinLogging import okio.buffer import okio.gzip @@ -70,6 +74,7 @@ object ProtoBackupExport : ProtoBackupBase() { ) } + @OptIn(DelicateCoroutinesApi::class) fun scheduleAutomatedBackupTask() { HAScheduler.descheduleCron(backupSchedulerJobId) @@ -94,7 +99,9 @@ object ProtoBackupExport : ProtoBackupBase() { val wasPreviousBackupTriggered = (System.currentTimeMillis() - lastAutomatedBackup) < backupInterval.inWholeMilliseconds if (!wasPreviousBackupTriggered) { - task() + GlobalScope.launch(Dispatchers.IO) { + task() + } } HAScheduler.scheduleCron(task, "$backupMinute $backupHour */${backupInterval.inWholeDays} * *", "backup") 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 3fe270ae..4b1cd84a 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 @@ -5,8 +5,10 @@ import android.content.Context import eu.kanade.tachiyomi.source.model.UpdateStrategy import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancelChildren import kotlinx.coroutines.channels.BufferOverflow @@ -124,6 +126,7 @@ class Updater : IUpdater { addCategoriesToUpdateQueue(Category.getCategoryList(), clear = true, forceAll = false) } + @OptIn(DelicateCoroutinesApi::class) fun scheduleUpdateTask() { HAScheduler.deschedule(currentUpdateTaskId) @@ -141,7 +144,9 @@ class Updater : IUpdater { if (lastAutomatedUpdate > 0) lastAutomatedUpdate else System.currentTimeMillis() ) < updateInterval if (!wasPreviousUpdateTriggered) { - autoUpdateTask() + GlobalScope.launch { + autoUpdateTask() + } } HAScheduler.schedule(::autoUpdateTask, updateInterval, timeToNextExecution, "global-update") diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt index 0f5d98aa..7e3f8f7c 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt @@ -13,8 +13,10 @@ import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.awaitSuccess import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.FlowPreview +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.channels.BufferOverflow.DROP_OLDEST import kotlinx.coroutines.flow.MutableSharedFlow @@ -234,6 +236,7 @@ object WebInterfaceManager { return serverConfig.webUIUpdateCheckInterval.value.toInt() != 0 } + @OptIn(DelicateCoroutinesApi::class) private fun scheduleWebUIUpdateCheck() { HAScheduler.descheduleCron(currentUpdateTaskId) @@ -266,7 +269,9 @@ object WebInterfaceManager { val wasPreviousUpdateCheckTriggered = (System.currentTimeMillis() - lastAutomatedUpdate) < updateInterval.inWholeMilliseconds if (!wasPreviousUpdateCheckTriggered) { - task() + GlobalScope.launch(Dispatchers.IO) { + task() + } } currentUpdateTaskId =