mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-10 06:42:07 +01:00
Fix/initial auto backup never triggered in case server was not running (#762)
* Trigger initial auto backup in case server was not running In case the server was not started (stopped, system shutdown - not in hibernation) during the scheduled auto backup time, the auto backup never got triggered. * Update server util preferences
This commit is contained in:
@@ -54,8 +54,8 @@ object ProtoBackupExport : ProtoBackupBase() {
|
||||
private val logger = KotlinLogging.logger { }
|
||||
private val applicationDirs by DI.global.instance<ApplicationDirs>()
|
||||
private var backupSchedulerJobId: String = ""
|
||||
private const val LAST_AUTOMATED_BACKUP_KEY = "lastAutomatedBackupKey"
|
||||
private val preferences = Injekt.get<Application>().getSharedPreferences("manga/impl/backup/proto", Context.MODE_PRIVATE)
|
||||
private const val LAST_AUTOMATED_BACKUP_KEY = "lastAutomatedBackup"
|
||||
private val preferences = Injekt.get<Application>().getSharedPreferences("server_util", Context.MODE_PRIVATE)
|
||||
|
||||
init {
|
||||
serverConfig.subscribeTo(
|
||||
@@ -89,7 +89,7 @@ object ProtoBackupExport : ProtoBackupBase() {
|
||||
val backupInterval = serverConfig.backupInterval.value.days.coerceAtLeast(1.days)
|
||||
|
||||
// trigger last backup in case the server wasn't running on the scheduled time
|
||||
val lastAutomatedBackup = preferences.getLong(LAST_AUTOMATED_BACKUP_KEY, System.currentTimeMillis())
|
||||
val lastAutomatedBackup = preferences.getLong(LAST_AUTOMATED_BACKUP_KEY, 0)
|
||||
val wasPreviousBackupTriggered =
|
||||
(System.currentTimeMillis() - lastAutomatedBackup) < backupInterval.inWholeMilliseconds
|
||||
if (!wasPreviousBackupTriggered) {
|
||||
|
||||
@@ -51,9 +51,9 @@ class Updater : IUpdater {
|
||||
private var maxSourcesInParallel = 20 // max permits, necessary to be set to be able to release up to 20 permits
|
||||
private val semaphore = Semaphore(maxSourcesInParallel)
|
||||
|
||||
private val lastUpdateKey = "lastUpdateKey"
|
||||
private val lastAutomatedUpdateKey = "lastAutomatedUpdateKey"
|
||||
private val preferences = Injekt.get<Application>().getSharedPreferences("manga/impl/update", Context.MODE_PRIVATE)
|
||||
private val lastUpdateKey = "lastGlobalUpdate"
|
||||
private val lastAutomatedUpdateKey = "lastAutomatedGlobalUpdate"
|
||||
private val preferences = Injekt.get<Application>().getSharedPreferences("server_util", Context.MODE_PRIVATE)
|
||||
|
||||
private var currentUpdateTaskId = ""
|
||||
|
||||
|
||||
@@ -125,9 +125,9 @@ object WebInterfaceManager {
|
||||
private val logger = KotlinLogging.logger {}
|
||||
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
|
||||
|
||||
private const val LAST_WEBUI_UPDATE_CHECK_KEY = "lastWebUIUpdateCheckKey"
|
||||
private const val LAST_WEBUI_UPDATE_CHECK_KEY = "lastWebUIUpdateCheck"
|
||||
|
||||
private val preferences = Injekt.get<Application>().getSharedPreferences("server/util", Context.MODE_PRIVATE)
|
||||
private val preferences = Injekt.get<Application>().getSharedPreferences("server_util", Context.MODE_PRIVATE)
|
||||
private var currentUpdateTaskId: String = ""
|
||||
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
Reference in New Issue
Block a user