Fix cancelling library updates not working
(cherry picked from commit c4716a3f4c9ff9b53863d1f1267056c8f153c0c7) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt
This commit is contained in:
parent
deaefe8fa6
commit
26385c9225
@ -48,6 +48,7 @@ import exh.source.getMainSource
|
|||||||
import exh.source.mangaDexSourceIds
|
import exh.source.mangaDexSourceIds
|
||||||
import exh.util.executeOnIO
|
import exh.util.executeOnIO
|
||||||
import exh.util.nullIfBlank
|
import exh.util.nullIfBlank
|
||||||
|
import kotlinx.coroutines.CancellationException
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
@ -336,6 +337,10 @@ class LibraryUpdateService(
|
|||||||
|
|
||||||
mangaToUpdate
|
mangaToUpdate
|
||||||
.mapNotNull { manga ->
|
.mapNotNull { manga ->
|
||||||
|
if (updateJob?.isActive != true) {
|
||||||
|
throw CancellationException()
|
||||||
|
}
|
||||||
|
|
||||||
// Notify manga that will update.
|
// Notify manga that will update.
|
||||||
notifier.showProgressNotification(manga, progressCount.andIncrement, mangaToUpdate.size)
|
notifier.showProgressNotification(manga, progressCount.andIncrement, mangaToUpdate.size)
|
||||||
|
|
||||||
@ -457,6 +462,10 @@ class LibraryUpdateService(
|
|||||||
var progressCount = 0
|
var progressCount = 0
|
||||||
|
|
||||||
mangaToUpdate.forEach { manga ->
|
mangaToUpdate.forEach { manga ->
|
||||||
|
if (updateJob?.isActive != true) {
|
||||||
|
throw CancellationException()
|
||||||
|
}
|
||||||
|
|
||||||
notifier.showProgressNotification(manga, progressCount++, mangaToUpdate.size)
|
notifier.showProgressNotification(manga, progressCount++, mangaToUpdate.size)
|
||||||
|
|
||||||
sourceManager.get(manga.source)?.let { source ->
|
sourceManager.get(manga.source)?.let { source ->
|
||||||
@ -487,6 +496,10 @@ class LibraryUpdateService(
|
|||||||
val loggedServices = trackManager.services.filter { it.isLogged }
|
val loggedServices = trackManager.services.filter { it.isLogged }
|
||||||
|
|
||||||
mangaToUpdate.forEach { manga ->
|
mangaToUpdate.forEach { manga ->
|
||||||
|
if (updateJob?.isActive != true) {
|
||||||
|
throw CancellationException()
|
||||||
|
}
|
||||||
|
|
||||||
// Notify manga that will update.
|
// Notify manga that will update.
|
||||||
notifier.showProgressNotification(manga, progressCount++, mangaToUpdate.size)
|
notifier.showProgressNotification(manga, progressCount++, mangaToUpdate.size)
|
||||||
|
|
||||||
@ -528,7 +541,12 @@ class LibraryUpdateService(
|
|||||||
}
|
}
|
||||||
|
|
||||||
mangadexFollows.forEach { (networkManga, metadata) ->
|
mangadexFollows.forEach { (networkManga, metadata) ->
|
||||||
|
if (updateJob?.isActive != true) {
|
||||||
|
throw CancellationException()
|
||||||
|
}
|
||||||
|
|
||||||
notifier.showProgressNotification(networkManga, count.andIncrement, mangadexFollows.size)
|
notifier.showProgressNotification(networkManga, count.andIncrement, mangadexFollows.size)
|
||||||
|
|
||||||
var dbManga = db.getManga(networkManga.url, mangaDex.id)
|
var dbManga = db.getManga(networkManga.url, mangaDex.id)
|
||||||
.executeOnIO()
|
.executeOnIO()
|
||||||
if (dbManga == null) {
|
if (dbManga == null) {
|
||||||
@ -562,6 +580,10 @@ class LibraryUpdateService(
|
|||||||
// filter all follows from Mangadex and only add reading or rereading manga to library
|
// filter all follows from Mangadex and only add reading or rereading manga to library
|
||||||
if (trackManager.mdList.isLogged) {
|
if (trackManager.mdList.isLogged) {
|
||||||
listManga.forEach { manga ->
|
listManga.forEach { manga ->
|
||||||
|
if (updateJob?.isActive != true) {
|
||||||
|
throw CancellationException()
|
||||||
|
}
|
||||||
|
|
||||||
notifier.showProgressNotification(manga, count.andIncrement, listManga.size)
|
notifier.showProgressNotification(manga, count.andIncrement, listManga.size)
|
||||||
|
|
||||||
// Get this manga's trackers from the database
|
// Get this manga's trackers from the database
|
||||||
|
Loading…
x
Reference in New Issue
Block a user