Fix sources list of one source throws an exception (#308)

This commit is contained in:
Mitchell Syer
2022-03-20 11:54:09 -04:00
committed by GitHub
parent 44ffed3f7c
commit a27af0b642
2 changed files with 4 additions and 2 deletions

View File

@@ -24,6 +24,7 @@ import suwayomi.tachidesk.manga.impl.extension.Extension.getExtensionIconUrl
import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.getCatalogueSource
import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.getCatalogueSourceOrStub
import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.unregisterCatalogueSource
import suwayomi.tachidesk.manga.impl.util.source.StubSource
import suwayomi.tachidesk.manga.model.dataclass.SourceDataClass
import suwayomi.tachidesk.manga.model.table.ExtensionTable
import suwayomi.tachidesk.manga.model.table.SourceTable
@@ -36,8 +37,9 @@ object Source {
fun getSourceList(): List<SourceDataClass> {
return transaction {
SourceTable.selectAll().map {
SourceTable.selectAll().mapNotNull {
val catalogueSource = getCatalogueSourceOrStub(it[SourceTable.id].value)
if (catalogueSource is StubSource) return@mapNotNull null
val sourceExtension = ExtensionTable.select { ExtensionTable.id eq it[SourceTable.extension] }.first()
SourceDataClass(

View File

@@ -57,7 +57,7 @@ object GetCatalogueSource {
}
fun getCatalogueSourceOrStub(sourceId: Long): CatalogueSource {
return getCatalogueSource(sourceId) ?: StubSource(sourceId)
return runCatching { getCatalogueSource(sourceId) }.getOrNull() ?: StubSource(sourceId)
}
fun registerCatalogueSource(sourcePair: Pair<Long, CatalogueSource>) {