Don't apply Wi-Fi network restriction for manual library update jobs
Fixes #9074
This commit is contained in:
parent
be4072c86b
commit
4d607c4aed
1 changed files with 7 additions and 7 deletions
|
@ -108,13 +108,13 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
||||||
private var mangaToUpdate: List<LibraryManga> = mutableListOf()
|
private var mangaToUpdate: List<LibraryManga> = mutableListOf()
|
||||||
|
|
||||||
override suspend fun doWork(): Result {
|
override suspend fun doWork(): Result {
|
||||||
val preferences = Injekt.get<LibraryPreferences>()
|
|
||||||
val restrictions = preferences.libraryUpdateDeviceRestriction().get()
|
|
||||||
if ((DEVICE_ONLY_ON_WIFI in restrictions) && !context.isConnectedToWifi()) {
|
|
||||||
return Result.failure()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tags.contains(WORK_NAME_AUTO)) {
|
if (tags.contains(WORK_NAME_AUTO)) {
|
||||||
|
val preferences = Injekt.get<LibraryPreferences>()
|
||||||
|
val restrictions = preferences.libraryUpdateDeviceRestriction().get()
|
||||||
|
if ((DEVICE_ONLY_ON_WIFI in restrictions) && !context.isConnectedToWifi()) {
|
||||||
|
return Result.failure()
|
||||||
|
}
|
||||||
|
|
||||||
// Find a running manual worker. If exists, try again later
|
// Find a running manual worker. If exists, try again later
|
||||||
val otherRunningWorker = withContext(Dispatchers.IO) {
|
val otherRunningWorker = withContext(Dispatchers.IO) {
|
||||||
WorkManager.getInstance(context)
|
WorkManager.getInstance(context)
|
||||||
|
@ -135,7 +135,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
||||||
|
|
||||||
val target = inputData.getString(KEY_TARGET)?.let { Target.valueOf(it) } ?: Target.CHAPTERS
|
val target = inputData.getString(KEY_TARGET)?.let { Target.valueOf(it) } ?: Target.CHAPTERS
|
||||||
|
|
||||||
// If this is a chapter update; set the last update time to now
|
// If this is a chapter update, set the last update time to now
|
||||||
if (target == Target.CHAPTERS) {
|
if (target == Target.CHAPTERS) {
|
||||||
libraryPreferences.libraryUpdateLastTimestamp().set(Date().time)
|
libraryPreferences.libraryUpdateLastTimestamp().set(Date().time)
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue