mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 20:31:02 -05:00
Enforce maximum extension lib version of 1.2
This commit is contained in:
parent
e1eff7b744
commit
2f69317f5d
2 changed files with 22 additions and 15 deletions
|
@ -7,6 +7,7 @@ import com.github.salomonbrys.kotson.string
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.JsonArray
|
import com.google.gson.JsonArray
|
||||||
import eu.kanade.tachiyomi.extension.model.Extension
|
import eu.kanade.tachiyomi.extension.model.Extension
|
||||||
|
import eu.kanade.tachiyomi.extension.util.ExtensionLoader
|
||||||
import eu.kanade.tachiyomi.network.GET
|
import eu.kanade.tachiyomi.network.GET
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||||
|
@ -36,7 +37,13 @@ internal class ExtensionGithubApi {
|
||||||
|
|
||||||
val json = gson.fromJson<JsonArray>(text)
|
val json = gson.fromJson<JsonArray>(text)
|
||||||
|
|
||||||
return json.map { element ->
|
return json
|
||||||
|
.filter { element ->
|
||||||
|
val versionName = element["version"].string
|
||||||
|
val libVersion = versionName.substringBeforeLast('.').toDouble()
|
||||||
|
libVersion >= ExtensionLoader.LIB_VERSION_MIN && libVersion <= ExtensionLoader.LIB_VERSION_MAX
|
||||||
|
}
|
||||||
|
.map { element ->
|
||||||
val name = element["name"].string.substringAfter("Tachiyomi: ")
|
val name = element["name"].string.substringAfter("Tachiyomi: ")
|
||||||
val pkgName = element["pkg"].string
|
val pkgName = element["pkg"].string
|
||||||
val apkName = element["apk"].string
|
val apkName = element["apk"].string
|
||||||
|
|
|
@ -27,8 +27,8 @@ internal object ExtensionLoader {
|
||||||
|
|
||||||
private const val EXTENSION_FEATURE = "tachiyomi.extension"
|
private const val EXTENSION_FEATURE = "tachiyomi.extension"
|
||||||
private const val METADATA_SOURCE_CLASS = "tachiyomi.extension.class"
|
private const val METADATA_SOURCE_CLASS = "tachiyomi.extension.class"
|
||||||
private const val LIB_VERSION_MIN = 1
|
const val LIB_VERSION_MIN = 1.0
|
||||||
private const val LIB_VERSION_MAX = 1
|
const val LIB_VERSION_MAX = 1.2
|
||||||
|
|
||||||
private const val PACKAGE_FLAGS = PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES
|
private const val PACKAGE_FLAGS = PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES
|
||||||
|
|
||||||
|
@ -107,9 +107,9 @@ internal object ExtensionLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate lib version
|
// Validate lib version
|
||||||
val majorLibVersion = versionName.substringBefore('.').toInt()
|
val libVersion = versionName.substringBeforeLast('.').toDouble()
|
||||||
if (majorLibVersion < LIB_VERSION_MIN || majorLibVersion > LIB_VERSION_MAX) {
|
if (libVersion < LIB_VERSION_MIN || libVersion > LIB_VERSION_MAX) {
|
||||||
val exception = Exception("Lib version is $majorLibVersion, while only versions " +
|
val exception = Exception("Lib version is $libVersion, while only versions " +
|
||||||
"$LIB_VERSION_MIN to $LIB_VERSION_MAX are allowed")
|
"$LIB_VERSION_MIN to $LIB_VERSION_MAX are allowed")
|
||||||
Timber.w(exception)
|
Timber.w(exception)
|
||||||
return LoadResult.Error(exception)
|
return LoadResult.Error(exception)
|
||||||
|
|
Loading…
Reference in a new issue