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