mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-10 06:42:07 +01:00
Fix/missed automated task execution failure crashes server on startup (#1019)
* Catch automated backup task errors * Catch automated udpate task errors * Catch automated webui update task errors
This commit is contained in:
@@ -84,9 +84,13 @@ object ProtoBackupExport : ProtoBackupBase() {
|
||||
}
|
||||
|
||||
val task = {
|
||||
cleanupAutomatedBackups()
|
||||
createAutomatedBackup()
|
||||
preferences.edit().putLong(LAST_AUTOMATED_BACKUP_KEY, System.currentTimeMillis()).apply()
|
||||
try {
|
||||
cleanupAutomatedBackups()
|
||||
createAutomatedBackup()
|
||||
preferences.edit().putLong(LAST_AUTOMATED_BACKUP_KEY, System.currentTimeMillis()).apply()
|
||||
} catch (e: Exception) {
|
||||
logger.error(e) { "scheduleAutomatedBackupTask: failed due to" }
|
||||
}
|
||||
}
|
||||
|
||||
val (hour, minute) = serverConfig.backupTime.value.split(":").map { it.toInt() }
|
||||
|
||||
@@ -110,20 +110,24 @@ class Updater : IUpdater {
|
||||
}
|
||||
|
||||
private fun autoUpdateTask() {
|
||||
val lastAutomatedUpdate = preferences.getLong(lastAutomatedUpdateKey, 0)
|
||||
preferences.edit().putLong(lastAutomatedUpdateKey, System.currentTimeMillis()).apply()
|
||||
try {
|
||||
val lastAutomatedUpdate = preferences.getLong(lastAutomatedUpdateKey, 0)
|
||||
preferences.edit().putLong(lastAutomatedUpdateKey, System.currentTimeMillis()).apply()
|
||||
|
||||
if (getStatus().running) {
|
||||
logger.debug { "Global update is already in progress" }
|
||||
return
|
||||
}
|
||||
if (getStatus().running) {
|
||||
logger.debug { "Global update is already in progress" }
|
||||
return
|
||||
}
|
||||
|
||||
logger.info {
|
||||
"Trigger global update (interval= ${serverConfig.globalUpdateInterval.value}h, lastAutomatedUpdate= ${Date(
|
||||
lastAutomatedUpdate,
|
||||
)})"
|
||||
logger.info {
|
||||
"Trigger global update (interval= ${serverConfig.globalUpdateInterval.value}h, lastAutomatedUpdate= ${Date(
|
||||
lastAutomatedUpdate,
|
||||
)})"
|
||||
}
|
||||
addCategoriesToUpdateQueue(Category.getCategoryList(), clear = true, forceAll = false)
|
||||
} catch (e: Exception) {
|
||||
logger.error(e) { "autoUpdateTask: failed due to" }
|
||||
}
|
||||
addCategoriesToUpdateQueue(Category.getCategoryList(), clear = true, forceAll = false)
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
|
||||
@@ -249,20 +249,26 @@ object WebInterfaceManager {
|
||||
val lastAutomatedUpdate = preferences.getLong(LAST_WEBUI_UPDATE_CHECK_KEY, System.currentTimeMillis())
|
||||
|
||||
val task = {
|
||||
logger.debug {
|
||||
"Checking for webUI update (" +
|
||||
"flavor= ${WebUIFlavor.current.uiName}, " +
|
||||
"channel= ${serverConfig.webUIChannel.value}, " +
|
||||
"interval= ${serverConfig.webUIUpdateCheckInterval.value}h, " +
|
||||
"lastAutomatedUpdate= ${
|
||||
Date(
|
||||
lastAutomatedUpdate,
|
||||
)
|
||||
})"
|
||||
}
|
||||
val log =
|
||||
KotlinLogging.logger(
|
||||
"${logger.name}::scheduleWebUIUpdateCheck(" +
|
||||
"flavor= ${WebUIFlavor.current.uiName}, " +
|
||||
"channel= ${serverConfig.webUIChannel.value}, " +
|
||||
"interval= ${serverConfig.webUIUpdateCheckInterval.value}h, " +
|
||||
"lastAutomatedUpdate= ${
|
||||
Date(
|
||||
lastAutomatedUpdate,
|
||||
)
|
||||
})",
|
||||
)
|
||||
log.debug { "called" }
|
||||
|
||||
runBlocking {
|
||||
checkForUpdate(WebUIFlavor.current)
|
||||
try {
|
||||
checkForUpdate(WebUIFlavor.current)
|
||||
} catch (e: Exception) {
|
||||
log.error(e) { "failed due to" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user