fixes from inspector

This commit is contained in:
Aria Moradi 2021-04-03 20:08:50 +04:30
parent 15bd5b4b7a
commit 884308690f
2 changed files with 13 additions and 19 deletions

View File

@ -47,8 +47,8 @@ object Extension {
private val logger = KotlinLogging.logger {}
data class InstallableAPK(
val apkFilePath: String,
val pkgName: String
val apkFilePath: String,
val pkgName: String
)
suspend fun installExtension(pkgName: String): Int {
@ -94,8 +94,8 @@ object Extension {
val libVersion = packageInfo.versionName.substringBeforeLast('.').toDouble()
if (libVersion < LIB_VERSION_MIN || libVersion > LIB_VERSION_MAX) {
throw Exception(
"Lib version is $libVersion, while only versions " +
"$LIB_VERSION_MIN to $LIB_VERSION_MAX are allowed"
"Lib version is $libVersion, while only versions " +
"$LIB_VERSION_MIN to $LIB_VERSION_MAX are allowed"
)
}
@ -124,10 +124,7 @@ object Extension {
val sources: List<CatalogueSource> = when (val instance = loadExtensionSources(jarFilePath, className)) {
is Source -> listOf(instance)
is SourceFactory -> instance.createSources()
else -> {
throw RuntimeException("Unknown source class type! ${instance.javaClass}")
}
else -> throw RuntimeException("Unknown source class type! ${instance.javaClass}")
}.map { it as CatalogueSource }
val langs = sources.map { it.lang }.toSet()
@ -239,7 +236,7 @@ object Extension {
return getCachedImageResponse(saveDir, apkName) {
network.client.newCall(
GET(iconUrl)
GET(iconUrl)
).await()
}
}

View File

@ -7,6 +7,7 @@ package ir.armor.tachidesk.impl.util
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceFactory
import eu.kanade.tachiyomi.source.online.HttpSource
import ir.armor.tachidesk.impl.util.PackageTools.loadExtensionSources
@ -40,16 +41,12 @@ object GetHttpSource {
val jarName = apkName.substringBefore(".apk") + ".jar"
val jarPath = "${ApplicationDirs.extensionsRoot}/$jarName"
val extensionInstance = loadExtensionSources(jarPath, className)
if (sourceRecord[SourceTable.partOfFactorySource]) {
(extensionInstance as SourceFactory).createSources().forEach {
sourceCache[it.id] = it as HttpSource
}
} else {
(extensionInstance as HttpSource).also {
sourceCache[it.id] = it
}
when (val instance = loadExtensionSources(jarPath, className)) {
is Source -> listOf(instance)
is SourceFactory -> instance.createSources()
else -> throw Exception("Unknown source class type! ${instance.javaClass}")
}.forEach {
sourceCache[it.id] = it as HttpSource
}
return sourceCache[sourceId]!!
}