Do library checks from up to 5 sources concurrently

(cherry picked from commit f853158e6b)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt
This commit is contained in:
arkon
2020-05-08 18:58:49 -04:00
committed by Jobobby04
parent ce0d99b78f
commit f30ad78a4c

View File

@ -309,9 +309,13 @@ class LibraryUpdateService(
// Emit each manga and update it sequentially. // Emit each manga and update it sequentially.
return Observable.from(mangaToUpdate) return Observable.from(mangaToUpdate)
// Update the chapters of the manga concurrently from 5 different sources
.groupBy { it.source }
.flatMap(
{ bySource ->
bySource
// Notify manga that will update. // Notify manga that will update.
.doOnNext { showProgressNotification(it, count.andIncrement, mangaToUpdate.size) } .doOnNext { showProgressNotification(it, count.andIncrement, mangaToUpdate.size) }
// Update the chapters of the manga.
.concatMap { manga -> .concatMap { manga ->
if (manga.source in LIBRARY_UPDATE_EXCLUDED_SOURCES) { if (manga.source in LIBRARY_UPDATE_EXCLUDED_SOURCES) {
// Ignore EXH manga, updating chapters for every manga will get you banned // Ignore EXH manga, updating chapters for every manga will get you banned
@ -335,15 +339,21 @@ class LibraryUpdateService(
hasDownloads = true hasDownloads = true
} }
} }
}
// Convert to the manga that contains new chapters. // Convert to the manga that contains new chapters.
.map { .map {
Pair( Pair(
manga, manga,
(it.first.sortedByDescending { ch -> ch.source_order }.toTypedArray()) (
it.first.sortedByDescending { ch -> ch.source_order }
.toTypedArray()
)
) )
} }
} }
}
},
5
)
// Add manga with new chapters to the list. // Add manga with new chapters to the list.
.doOnNext { manga -> .doOnNext { manga ->
// Add to the list // Add to the list
@ -403,9 +413,13 @@ class LibraryUpdateService(
// Emit each manga and update it sequentially. // Emit each manga and update it sequentially.
return Observable.from(mangaToUpdate) return Observable.from(mangaToUpdate)
// Update the details of the manga concurrently from 5 different sources
.groupBy { it.source }
.flatMap(
{ bySource ->
bySource
// Notify manga that will update. // Notify manga that will update.
.doOnNext { showProgressNotification(it, count.andIncrement, mangaToUpdate.size) } .doOnNext { showProgressNotification(it, count.andIncrement, mangaToUpdate.size) }
// Update the details of the manga.
.concatMap { manga -> .concatMap { manga ->
val source = sourceManager.get(manga.source) as? HttpSource val source = sourceManager.get(manga.source) as? HttpSource
?: return@concatMap Observable.empty<LibraryManga>() ?: return@concatMap Observable.empty<LibraryManga>()
@ -418,6 +432,9 @@ class LibraryUpdateService(
} }
.onErrorReturn { manga } .onErrorReturn { manga }
} }
},
5
)
.doOnCompleted { .doOnCompleted {
cancelProgressNotification() cancelProgressNotification()
} }