Temporarily revert concurrent manga updates

This commit is contained in:
arkon 2020-05-10 23:13:58 -04:00
parent 6b71264482
commit e208fa4020
2 changed files with 36 additions and 43 deletions

View File

@ -263,46 +263,39 @@ 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 // Notify manga that will update.
.groupBy { it.source } .doOnNext { notifier.showProgressNotification(it, count.andIncrement, mangaToUpdate.size) }
.flatMap( // Update the chapters of the manga
{ bySource -> .concatMap { manga ->
bySource updateManga(manga)
// Notify manga that will update. // If there's any error, return empty update and continue.
.doOnNext { notifier.showProgressNotification(it, count.andIncrement, mangaToUpdate.size) } .onErrorReturn {
.concatMap { manga -> failedUpdates.add(manga)
updateManga(manga) Pair(emptyList(), emptyList())
// If there's any error, return empty update and continue. }
.onErrorReturn { // Filter out mangas without new chapters (or failed).
failedUpdates.add(manga) .filter { pair -> pair.first.isNotEmpty() }
Pair(emptyList(), emptyList()) .doOnNext {
} if (downloadNew && (
// Filter out mangas without new chapters (or failed). categoriesToDownload.isEmpty() ||
.filter { pair -> pair.first.isNotEmpty() } manga.category in categoriesToDownload
.doOnNext { )
if (downloadNew && ( ) {
categoriesToDownload.isEmpty() || downloadChapters(manga, it.first)
manga.category in categoriesToDownload hasDownloads = true
)
) {
downloadChapters(manga, it.first)
hasDownloads = true
}
}
// Convert to the manga that contains new chapters.
.map {
Pair(
manga,
(
it.first.sortedByDescending { ch -> ch.source_order }
.toTypedArray()
)
)
}
} }
}, }
5 // Convert to the manga that contains new chapters.
) .map {
Pair(
manga,
(
it.first.sortedByDescending { ch -> ch.source_order }
.toTypedArray()
)
)
}
}
// 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
@ -326,7 +319,7 @@ class LibraryUpdateService(
.map { manga -> manga.first } .map { manga -> manga.first }
} }
fun downloadChapters(manga: Manga, chapters: List<Chapter>) { private fun downloadChapters(manga: Manga, chapters: List<Chapter>) {
// we need to get the chapters from the db so we have chapter ids // we need to get the chapters from the db so we have chapter ids
val mangaChapters = db.getChapters(manga).executeAsBlocking() val mangaChapters = db.getChapters(manga).executeAsBlocking()
val dbChapters = chapters.map { val dbChapters = chapters.map {

View File

@ -19,7 +19,7 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory
import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.switchPreference
import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.preference.titleRes
import eu.kanade.tachiyomi.util.system.LocaleHelper import eu.kanade.tachiyomi.util.system.LocaleHelper
import java.util.Calendar import java.util.Date
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
class SettingsGeneralController : SettingsController() { class SettingsGeneralController : SettingsController() {
@ -94,9 +94,9 @@ class SettingsGeneralController : SettingsController() {
titleRes = R.string.pref_date_format titleRes = R.string.pref_date_format
entryValues = arrayOf("", "MM/dd/yy", "dd/MM/yy", "yyyy-MM-dd") entryValues = arrayOf("", "MM/dd/yy", "dd/MM/yy", "yyyy-MM-dd")
val currentDate = Calendar.getInstance().time val now = Date().time
entries = entryValues.map { value -> entries = entryValues.map { value ->
val formattedDate = preferences.dateFormat(value.toString()).format(currentDate) val formattedDate = preferences.dateFormat(value.toString()).format(now)
if (value == "") { if (value == "") {
"${context.getString(R.string.system_default)} ($formattedDate)" "${context.getString(R.string.system_default)} ($formattedDate)"
} else { } else {