diff --git a/server/src/main/kotlin/ir/armor/tachidesk/impl/Extension.kt b/server/src/main/kotlin/ir/armor/tachidesk/impl/Extension.kt index c821a45..735cfec 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/impl/Extension.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/impl/Extension.kt @@ -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 = 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() } } diff --git a/server/src/main/kotlin/ir/armor/tachidesk/impl/util/GetHttpSource.kt b/server/src/main/kotlin/ir/armor/tachidesk/impl/util/GetHttpSource.kt index 5ed05c3..41eb4ec 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/impl/util/GetHttpSource.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/impl/util/GetHttpSource.kt @@ -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]!! }