Avoid loading available extensions list if it seems too small
(cherry picked from commit 6a39c8fc13)
# Conflicts:
# app/src/main/java/eu/kanade/tachiyomi/extension/api/ExtensionGithubApi.kt
This commit is contained in:
@@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.extension.util.ExtensionLoader
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.util.lang.launchNow
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import exh.log.xLogD
|
||||
import exh.source.BlacklistedSources
|
||||
@@ -24,6 +25,7 @@ import exh.source.EH_SOURCE_ID
|
||||
import exh.source.EXH_SOURCE_ID
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import kotlinx.coroutines.async
|
||||
import logcat.LogPriority
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
@@ -198,7 +200,8 @@ class ExtensionManager(
|
||||
val extensions: List<Extension.Available> = try {
|
||||
api.findExtensions()
|
||||
} catch (e: Exception) {
|
||||
context.toast(e.message)
|
||||
logcat(LogPriority.ERROR, e)
|
||||
context.toast(R.string.extension_api_error)
|
||||
emptyList()
|
||||
}
|
||||
|
||||
|
||||
@@ -23,20 +23,30 @@ internal class ExtensionGithubApi {
|
||||
|
||||
suspend fun findExtensions(): List<Extension.Available> {
|
||||
return withIOContext {
|
||||
networkService.client
|
||||
val extensions = networkService.client
|
||||
.newCall(GET("${REPO_URL_PREFIX}index.min.json"))
|
||||
.await()
|
||||
.parseAs<List<ExtensionJsonObject>>()
|
||||
.toExtensions()
|
||||
} /* SY --> */ + preferences.extensionRepos().get().flatMap { repoPath ->
|
||||
val url = "$BASE_URL$repoPath/repo/"
|
||||
networkService.client
|
||||
.newCall(GET("${url}index.min.json"))
|
||||
.await()
|
||||
.parseAs<List<ExtensionJsonObject>>()
|
||||
.toExtensions(url)
|
||||
.toExtensions() /* SY --> */ + preferences.extensionRepos()
|
||||
.get()
|
||||
.flatMap { repoPath ->
|
||||
val url = "$BASE_URL$repoPath/repo/"
|
||||
networkService.client
|
||||
.newCall(GET("${url}index.min.json"))
|
||||
.await()
|
||||
.parseAs<List<ExtensionJsonObject>>()
|
||||
.toExtensions(url)
|
||||
}
|
||||
// SY <--
|
||||
|
||||
// Sanity check - a small number of extensions probably means something broke
|
||||
// with the repo generator
|
||||
if (extensions.size < 100) {
|
||||
throw Exception()
|
||||
}
|
||||
|
||||
extensions
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
|
||||
suspend fun checkForUpdates(context: Context): List<Extension.Installed> {
|
||||
|
||||
Reference in New Issue
Block a user