mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2024-12-24 15:51:49 +01:00
flatten the code
This commit is contained in:
parent
640ce8f5d7
commit
68e69085df
@ -29,30 +29,32 @@ object Source {
|
||||
fun getHttpSource(sourceId: Long): HttpSource {
|
||||
val cachedResult: HttpSource? = sourceCache[sourceId]
|
||||
if (cachedResult != null) {
|
||||
logger.debug("used cached HttpSource: ${cachedResult.name}")
|
||||
return cachedResult
|
||||
}
|
||||
|
||||
transaction {
|
||||
val sourceRecord = SourceTable.select { SourceTable.id eq sourceId }.firstOrNull()!!
|
||||
val sourceRecord = transaction {
|
||||
SourceTable.select { SourceTable.id eq sourceId }.firstOrNull()!!
|
||||
}
|
||||
|
||||
val extensionId = sourceRecord[SourceTable.extension]
|
||||
val extensionRecord = ExtensionTable.select { ExtensionTable.id eq extensionId }.firstOrNull()!!
|
||||
val apkName = extensionRecord[ExtensionTable.apkName]
|
||||
val className = extensionRecord[ExtensionTable.classFQName]
|
||||
val jarName = apkName.substringBefore(".apk") + ".jar"
|
||||
val jarPath = "${ApplicationDirs.extensionsRoot}/$jarName"
|
||||
val extensionId = sourceRecord[SourceTable.extension]
|
||||
val extensionRecord = transaction {
|
||||
ExtensionTable.select { ExtensionTable.id eq extensionId }.firstOrNull()!!
|
||||
}
|
||||
|
||||
val extensionInstance = loadExtensionInstance(jarPath, className)
|
||||
val apkName = extensionRecord[ExtensionTable.apkName]
|
||||
val className = extensionRecord[ExtensionTable.classFQName]
|
||||
val jarName = apkName.substringBefore(".apk") + ".jar"
|
||||
val jarPath = "${ApplicationDirs.extensionsRoot}/$jarName"
|
||||
|
||||
if (sourceRecord[SourceTable.partOfFactorySource]) {
|
||||
(extensionInstance as SourceFactory).createSources().forEach {
|
||||
sourceCache[it.id] = it as HttpSource
|
||||
}
|
||||
} else {
|
||||
(extensionInstance as HttpSource).also {
|
||||
sourceCache[it.id] = it
|
||||
}
|
||||
val extensionInstance = loadExtensionInstance(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
|
||||
}
|
||||
}
|
||||
return sourceCache[sourceId]!!
|
||||
|
Loading…
Reference in New Issue
Block a user