Revert jsDelivr CDN fallback

It doesn't work unless you provide actual semver versions, but we don't do that.
This commit is contained in:
arkon 2021-07-20 17:23:55 -04:00 committed by Jays2Kings
parent 5e5feb6f12
commit db82cdedcb

View File

@ -20,23 +20,11 @@ internal class ExtensionGithubApi {
private val networkService: NetworkHelper by injectLazy() private val networkService: NetworkHelper by injectLazy()
private var requiresFallbackSource = false
suspend fun findExtensions(): List<Extension.Available> { suspend fun findExtensions(): List<Extension.Available> {
return withIOContext { return withIOContext {
val response = try {
networkService.client networkService.client
.newCall(GET("${REPO_URL_PREFIX}index.min.json")) .newCall(GET("${REPO_URL_PREFIX}index.min.json"))
.await() .await()
} catch (e: Throwable) {
requiresFallbackSource = true
networkService.client
.newCall(GET("${FALLBACK_REPO_URL_PREFIX}index.min.json"))
.await()
}
response
.parseAs<JsonArray>() .parseAs<JsonArray>()
.let { parseResponse(it) } .let { parseResponse(it) }
} }
@ -80,23 +68,15 @@ internal class ExtensionGithubApi {
val versionCode = element.jsonObject["code"]!!.jsonPrimitive.int val versionCode = element.jsonObject["code"]!!.jsonPrimitive.int
val lang = element.jsonObject["lang"]!!.jsonPrimitive.content val lang = element.jsonObject["lang"]!!.jsonPrimitive.content
val nsfw = element.jsonObject["nsfw"]!!.jsonPrimitive.int == 1 val nsfw = element.jsonObject["nsfw"]!!.jsonPrimitive.int == 1
val icon = "${getUrlPrefix()}icon/${apkName.replace(".apk", ".png")}" val icon = "${REPO_URL_PREFIX}icon/${apkName.replace(".apk", ".png")}"
Extension.Available(name, pkgName, versionName, versionCode, lang, nsfw, apkName, icon) Extension.Available(name, pkgName, versionName, versionCode, lang, nsfw, apkName, icon)
} }
} }
fun getApkUrl(extension: ExtensionManager.ExtensionInfo): String { fun getApkUrl(extension: ExtensionManager.ExtensionInfo): String {
return "${getUrlPrefix()}apk/${extension.apkName}" return "${REPO_URL_PREFIX}apk/${extension.apkName}"
}
private fun getUrlPrefix(): String {
return when (requiresFallbackSource) {
true -> FALLBACK_REPO_URL_PREFIX
false -> REPO_URL_PREFIX
}
} }
} }
private const val REPO_URL_PREFIX = "https://raw.githubusercontent.com/tachiyomiorg/tachiyomi-extensions/repo/" private const val REPO_URL_PREFIX = "https://raw.githubusercontent.com/tachiyomiorg/tachiyomi-extensions/repo/"
private const val FALLBACK_REPO_URL_PREFIX = "https://cdn.jsdelivr.net/gh/tachiyomiorg/tachiyomi-extensions@repo/"