mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 11:24:35 -05:00
Fix/load extension log load failure (#641)
* Log extension load failure In case the extension couldn't be loaded the error was never logged, making it impossible to analyse what was going on * Log exception in "GetCatalogueSource:: getCatalogueSourceOrNull" In case "GetCatalogueSource::getCatalogueSource" threw an error, this was never logged here
This commit is contained in:
@@ -143,12 +143,17 @@ object PackageTools {
|
|||||||
* It may return an instance of HttpSource or SourceFactory depending on the extension.
|
* It may return an instance of HttpSource or SourceFactory depending on the extension.
|
||||||
*/
|
*/
|
||||||
fun loadExtensionSources(jarPath: String, className: String): Any {
|
fun loadExtensionSources(jarPath: String, className: String): Any {
|
||||||
logger.debug { "loading jar with path: $jarPath" }
|
try {
|
||||||
val classLoader = jarLoaderMap[jarPath] ?: URLClassLoader(arrayOf<URL>(URL("file:$jarPath")))
|
logger.debug { "loading jar with path: $jarPath" }
|
||||||
val classToLoad = Class.forName(className, false, classLoader)
|
val classLoader = jarLoaderMap[jarPath] ?: URLClassLoader(arrayOf<URL>(URL("file:$jarPath")))
|
||||||
|
val classToLoad = Class.forName(className, false, classLoader)
|
||||||
|
|
||||||
jarLoaderMap[jarPath] = classLoader
|
jarLoaderMap[jarPath] = classLoader
|
||||||
|
|
||||||
return classToLoad.getDeclaredConstructor().newInstance()
|
return classToLoad.getDeclaredConstructor().newInstance()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logger.error(e) { "Failed to load jar with path: $jarPath" }
|
||||||
|
throw e
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.source.CatalogueSource
|
|||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.SourceFactory
|
import eu.kanade.tachiyomi.source.SourceFactory
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
|
import mu.KotlinLogging
|
||||||
import org.jetbrains.exposed.sql.select
|
import org.jetbrains.exposed.sql.select
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
import org.kodein.di.DI
|
import org.kodein.di.DI
|
||||||
@@ -23,6 +24,8 @@ import suwayomi.tachidesk.server.ApplicationDirs
|
|||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
object GetCatalogueSource {
|
object GetCatalogueSource {
|
||||||
|
private val logger = KotlinLogging.logger { }
|
||||||
|
|
||||||
private val sourceCache = ConcurrentHashMap<Long, CatalogueSource>()
|
private val sourceCache = ConcurrentHashMap<Long, CatalogueSource>()
|
||||||
private val applicationDirs by DI.global.instance<ApplicationDirs>()
|
private val applicationDirs by DI.global.instance<ApplicationDirs>()
|
||||||
|
|
||||||
@@ -57,7 +60,12 @@ object GetCatalogueSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getCatalogueSourceOrNull(sourceId: Long): CatalogueSource? {
|
fun getCatalogueSourceOrNull(sourceId: Long): CatalogueSource? {
|
||||||
return runCatching { getCatalogueSource(sourceId) }.getOrNull()
|
return try {
|
||||||
|
getCatalogueSource(sourceId)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
logger.warn(e) { "getCatalogueSource($sourceId) failed" }
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCatalogueSourceOrStub(sourceId: Long): CatalogueSource {
|
fun getCatalogueSourceOrStub(sourceId: Long): CatalogueSource {
|
||||||
|
|||||||
Reference in New Issue
Block a user