From e208fa402077165e69c738c95398c5216544ad3e Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 10 May 2020 23:13:58 -0400 Subject: [PATCH] Temporarily revert concurrent manga updates --- .../data/library/LibraryUpdateService.kt | 73 +++++++++---------- .../ui/setting/SettingsGeneralController.kt | 6 +- 2 files changed, 36 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index 79997473d..67db6e67a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -263,46 +263,39 @@ class LibraryUpdateService( // Emit each manga and update it sequentially. 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. - .doOnNext { notifier.showProgressNotification(it, count.andIncrement, mangaToUpdate.size) } - .concatMap { manga -> - updateManga(manga) - // If there's any error, return empty update and continue. - .onErrorReturn { - failedUpdates.add(manga) - Pair(emptyList(), emptyList()) - } - // Filter out mangas without new chapters (or failed). - .filter { pair -> pair.first.isNotEmpty() } - .doOnNext { - if (downloadNew && ( - categoriesToDownload.isEmpty() || - manga.category in categoriesToDownload - ) - ) { - 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() - ) - ) - } + // Notify manga that will update. + .doOnNext { notifier.showProgressNotification(it, count.andIncrement, mangaToUpdate.size) } + // Update the chapters of the manga + .concatMap { manga -> + updateManga(manga) + // If there's any error, return empty update and continue. + .onErrorReturn { + failedUpdates.add(manga) + Pair(emptyList(), emptyList()) + } + // Filter out mangas without new chapters (or failed). + .filter { pair -> pair.first.isNotEmpty() } + .doOnNext { + if (downloadNew && ( + categoriesToDownload.isEmpty() || + manga.category in categoriesToDownload + ) + ) { + downloadChapters(manga, it.first) + hasDownloads = true } - }, - 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. .doOnNext { manga -> // Add to the list @@ -326,7 +319,7 @@ class LibraryUpdateService( .map { manga -> manga.first } } - fun downloadChapters(manga: Manga, chapters: List) { + private fun downloadChapters(manga: Manga, chapters: List) { // we need to get the chapters from the db so we have chapter ids val mangaChapters = db.getChapters(manga).executeAsBlocking() val dbChapters = chapters.map { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt index d5696821a..da7babb09 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsGeneralController.kt @@ -19,7 +19,7 @@ import eu.kanade.tachiyomi.util.preference.preferenceCategory import eu.kanade.tachiyomi.util.preference.switchPreference import eu.kanade.tachiyomi.util.preference.titleRes import eu.kanade.tachiyomi.util.system.LocaleHelper -import java.util.Calendar +import java.util.Date import kotlinx.coroutines.flow.launchIn class SettingsGeneralController : SettingsController() { @@ -94,9 +94,9 @@ class SettingsGeneralController : SettingsController() { titleRes = R.string.pref_date_format entryValues = arrayOf("", "MM/dd/yy", "dd/MM/yy", "yyyy-MM-dd") - val currentDate = Calendar.getInstance().time + val now = Date().time entries = entryValues.map { value -> - val formattedDate = preferences.dateFormat(value.toString()).format(currentDate) + val formattedDate = preferences.dateFormat(value.toString()).format(now) if (value == "") { "${context.getString(R.string.system_default)} ($formattedDate)" } else {