fix(migration): Throttle E-Hentai requests (#1420)

This commit is contained in:
Cuong-Tran 2026-01-26 13:43:00 +07:00 committed by GitHub
parent 7e71162519
commit 505c8c23f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,6 +63,7 @@ class MigrationListScreenModel(
) : StateScreenModel<MigrationListScreenModel.State>(State()) {
private val smartSearchEngine = SmartSourceSearchEngine(extraSearchQuery)
// SY -->
private val throttleManager = ThrottleManager()
// SY <--
@ -133,8 +134,10 @@ class MigrationListScreenModel(
}
private suspend fun runMigrations(mangas: List<MigratingManga>) {
// KMK -->
// SY -->
throttleManager.resetThrottle()
// SY <--
// KMK -->
// val prioritizeByChapters = preferences.migrationPrioritizeByChapters().get()
// val deepSearchMode = preferences.migrationDeepSearchMode().get()
// KMK <--
@ -222,12 +225,11 @@ class MigrationListScreenModel(
val localManga = networkToLocalManga(searchResult)
try {
val chapters =
// KMK -->
if (source is EHentai) {
// SY -->
val chapters = if (source is EHentai) {
source.getChapterList(localManga.toSManga(), throttleManager::throttle)
} else {
// KMK <--
// SY <--
source.getChapterList(localManga.toSManga())
}
syncChaptersWithSource.await(chapters, localManga, source)
@ -271,7 +273,13 @@ class MigrationListScreenModel(
val manga = getManga.await(target) ?: return@async null
try {
val source = sourceManager.get(manga.source)!!
val chapters = source.getChapterList(manga.toSManga())
// SY -->
val chapters = if (source is EHentai) {
source.getChapterList(manga.toSManga(), throttleManager::throttle)
} else {
// SY <--
source.getChapterList(manga.toSManga())
}
syncChaptersWithSource.await(chapters, manga, source)
} catch (_: Exception) {
return@async null