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?).
This commit is contained in:
arkon 2023-12-11 22:02:22 -05:00
parent 720169dce3
commit 1ef01b53f2
3 changed files with 5 additions and 6 deletions

View File

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

View File

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

View File

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