Avoid starting restore job if already running

We already check in the settings screen where it's triggered, but who knows.
Also addressing some errors for method calls that require SDK 26+ (but don't
fail the build, somehow?).
pull/9853/head
arkon 9 months ago
parent 720169dce3
commit 1ef01b53f2

@ -17,8 +17,7 @@ import tachiyomi.core.util.system.logcat
import tachiyomi.domain.track.interactor.GetTracks import tachiyomi.domain.track.interactor.GetTracks
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import kotlin.time.Duration.Companion.minutes import java.util.concurrent.TimeUnit
import kotlin.time.toJavaDuration
class DelayedTrackingUpdateJob(private val context: Context, workerParams: WorkerParameters) : class DelayedTrackingUpdateJob(private val context: Context, workerParams: WorkerParameters) :
CoroutineWorker(context, workerParams) { CoroutineWorker(context, workerParams) {
@ -63,7 +62,7 @@ class DelayedTrackingUpdateJob(private val context: Context, workerParams: Worke
val request = OneTimeWorkRequestBuilder<DelayedTrackingUpdateJob>() val request = OneTimeWorkRequestBuilder<DelayedTrackingUpdateJob>()
.setConstraints(constraints) .setConstraints(constraints)
.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 5.minutes.toJavaDuration()) .setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 5, TimeUnit.MINUTES)
.addTag(TAG) .addTag(TAG)
.build() .build()

@ -27,8 +27,6 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import java.time.Instant import java.time.Instant
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlin.time.Duration.Companion.minutes
import kotlin.time.toJavaDuration
class BackupCreateJob(private val context: Context, workerParams: WorkerParameters) : class BackupCreateJob(private val context: Context, workerParams: WorkerParameters) :
CoroutineWorker(context, workerParams) { CoroutineWorker(context, workerParams) {
@ -97,7 +95,7 @@ class BackupCreateJob(private val context: Context, workerParams: WorkerParamete
10, 10,
TimeUnit.MINUTES, TimeUnit.MINUTES,
) )
.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 10.minutes.toJavaDuration()) .setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 10, TimeUnit.MINUTES)
.addTag(TAG_AUTO) .addTag(TAG_AUTO)
.setConstraints(constraints) .setConstraints(constraints)
.setInputData(workDataOf(IS_AUTO_BACKUP_KEY to true)) .setInputData(workDataOf(IS_AUTO_BACKUP_KEY to true))

@ -26,6 +26,8 @@ class BackupRestoreJob(private val context: Context, workerParams: WorkerParamet
private val notifier = BackupNotifier(context) private val notifier = BackupNotifier(context)
override suspend fun doWork(): Result { override suspend fun doWork(): Result {
if (isRunning(context)) return Result.failure()
val uri = inputData.getString(LOCATION_URI_KEY)?.toUri() val uri = inputData.getString(LOCATION_URI_KEY)?.toUri()
?: return Result.failure() ?: return Result.failure()
val sync = inputData.getBoolean(SYNC_KEY, false) val sync = inputData.getBoolean(SYNC_KEY, false)

Loading…
Cancel
Save