Avoid loading available extensions list if it seems too small
This commit is contained in:
parent
dc39669321
commit
6a39c8fc13
3 changed files with 15 additions and 2 deletions
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.extension
|
|||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import com.jakewharton.rxrelay.BehaviorRelay
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.plusAssign
|
||||
import eu.kanade.tachiyomi.extension.api.ExtensionGithubApi
|
||||
|
@ -15,8 +16,10 @@ 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 kotlinx.coroutines.async
|
||||
import logcat.LogPriority
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
@ -160,7 +163,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()
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,19 @@ 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()
|
||||
|
||||
// Sanity check - a small number of extensions probably means something broke
|
||||
// with the repo generator
|
||||
if (extensions.size < 100) {
|
||||
throw Exception()
|
||||
}
|
||||
|
||||
extensions
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -261,6 +261,7 @@
|
|||
<string name="untrusted_extension_message">This extension was signed with an untrusted certificate and wasn\'t activated.\n\nA malicious extension could read any login credentials stored in Tachiyomi or execute arbitrary code.\n\nBy trusting this certificate you accept these risks.</string>
|
||||
<string name="obsolete_extension_message">This extension is no longer available.</string>
|
||||
<string name="unofficial_extension_message">This extension is not from the official Tachiyomi extensions list.</string>
|
||||
<string name="extension_api_error">Failed to get extensions list</string>
|
||||
<string name="ext_version_info">Version: %1$s</string>
|
||||
<string name="ext_language_info">Language: %1$s</string>
|
||||
<string name="ext_nsfw_short">18+</string>
|
||||
|
|
Reference in a new issue