|
|
|
@ -3,7 +3,6 @@ package org.koitharu.kotatsu.local.ui
|
|
|
|
import android.content.Context
|
|
|
|
import android.content.Context
|
|
|
|
import androidx.hilt.work.HiltWorker
|
|
|
|
import androidx.hilt.work.HiltWorker
|
|
|
|
import androidx.work.BackoffPolicy
|
|
|
|
import androidx.work.BackoffPolicy
|
|
|
|
import androidx.work.Constraints
|
|
|
|
|
|
|
|
import androidx.work.CoroutineWorker
|
|
|
|
import androidx.work.CoroutineWorker
|
|
|
|
import androidx.work.ExistingWorkPolicy
|
|
|
|
import androidx.work.ExistingWorkPolicy
|
|
|
|
import androidx.work.OneTimeWorkRequestBuilder
|
|
|
|
import androidx.work.OneTimeWorkRequestBuilder
|
|
|
|
@ -46,11 +45,7 @@ class LocalStorageCleanupWorker @AssistedInject constructor(
|
|
|
|
private const val TAG = "cleanup"
|
|
|
|
private const val TAG = "cleanup"
|
|
|
|
|
|
|
|
|
|
|
|
suspend fun enqueue(context: Context) {
|
|
|
|
suspend fun enqueue(context: Context) {
|
|
|
|
val constraints = Constraints.Builder()
|
|
|
|
|
|
|
|
.setRequiresBatteryNotLow(true)
|
|
|
|
|
|
|
|
.build()
|
|
|
|
|
|
|
|
val request = OneTimeWorkRequestBuilder<LocalStorageCleanupWorker>()
|
|
|
|
val request = OneTimeWorkRequestBuilder<LocalStorageCleanupWorker>()
|
|
|
|
.setConstraints(constraints)
|
|
|
|
|
|
|
|
.addTag(TAG)
|
|
|
|
.addTag(TAG)
|
|
|
|
.setBackoffCriteria(BackoffPolicy.LINEAR, 10, TimeUnit.MINUTES)
|
|
|
|
.setBackoffCriteria(BackoffPolicy.LINEAR, 10, TimeUnit.MINUTES)
|
|
|
|
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
|
|
|
|
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
|
|
|
|
|