Avoid throw as it is slow expensive operations
(cherry picked from commit 9547311d7d40c98b951e679b7a5e4967cf73ee0d) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt
This commit is contained in:
parent
1cba2536af
commit
09bef11e6b
@ -397,16 +397,18 @@ class LibraryUpdateService(
|
|||||||
manga,
|
manga,
|
||||||
) { manga ->
|
) { manga ->
|
||||||
try {
|
try {
|
||||||
if (MANGA_NON_COMPLETED in restrictions && manga.status == SManga.COMPLETED) {
|
when {
|
||||||
throw SkipUpdateException(getString(R.string.skipped_reason_completed))
|
MANGA_NON_COMPLETED in restrictions && manga.status == SManga.COMPLETED -> {
|
||||||
|
skippedUpdates.add(manga to getString(R.string.skipped_reason_completed))
|
||||||
}
|
}
|
||||||
if (MANGA_HAS_UNREAD in restrictions && manga.unreadCount != 0) {
|
MANGA_HAS_UNREAD in restrictions && manga.unreadCount != 0 -> {
|
||||||
throw SkipUpdateException(getString(R.string.skipped_reason_not_caught_up))
|
skippedUpdates.add(manga to getString(R.string.skipped_reason_not_caught_up))
|
||||||
}
|
}
|
||||||
if (MANGA_NON_READ in restrictions && manga.totalChapters > 0 && !manga.hasStarted) {
|
MANGA_NON_READ in restrictions && manga.totalChapters > 0 && !manga.hasStarted -> {
|
||||||
throw SkipUpdateException(getString(R.string.skipped_reason_not_started))
|
skippedUpdates.add(manga to getString(R.string.skipped_reason_not_started))
|
||||||
}
|
}
|
||||||
|
else -> {
|
||||||
|
// Convert to the manga that contains new chapters
|
||||||
val (newChapters, _) = updateManga(manga, loggedServices)
|
val (newChapters, _) = updateManga(manga, loggedServices)
|
||||||
|
|
||||||
if (newChapters.isNotEmpty()) {
|
if (newChapters.isNotEmpty()) {
|
||||||
@ -421,8 +423,8 @@ class LibraryUpdateService(
|
|||||||
.toTypedArray()
|
.toTypedArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (e: SkipUpdateException) {
|
}
|
||||||
skippedUpdates.add(manga to e.message)
|
}
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
val errorMessage = when (e) {
|
val errorMessage = when (e) {
|
||||||
is NoChaptersException -> {
|
is NoChaptersException -> {
|
||||||
@ -778,5 +780,3 @@ class LibraryUpdateService(
|
|||||||
|
|
||||||
private const val MANGA_PER_SOURCE_QUEUE_WARNING_THRESHOLD = 60
|
private const val MANGA_PER_SOURCE_QUEUE_WARNING_THRESHOLD = 60
|
||||||
private const val ERROR_LOG_HELP_URL = "https://tachiyomi.org/help/guides/troubleshooting"
|
private const val ERROR_LOG_HELP_URL = "https://tachiyomi.org/help/guides/troubleshooting"
|
||||||
|
|
||||||
private class SkipUpdateException(override val message: String) : RuntimeException()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user