fix(书源导入):no path $.sourceUrls find

json.read找不到会抛出异常
This commit is contained in:
Xwite
2022-05-10 15:54:59 +08:00
parent a2f69a08ff
commit eee9097273
@@ -90,13 +90,14 @@ class ImportBookSourceViewModel(app: Application) : BaseViewModel(app) {
val mText = text.trim()
when {
mText.isJsonObject() -> {
val json = JsonPath.parse(mText)
val urls = json.read<List<String>>("$.sourceUrls")
if (!urls.isNullOrEmpty()) {
urls.forEach {
kotlin.runCatching {
val json = JsonPath.parse(mText)
json.read<List<String>>("$.sourceUrls")
}.onSuccess {
it.forEach {
importSourceUrl(it)
}
} else {
}.onFailure {
BookSource.fromJson(mText).getOrThrow().let {
allSources.add(it)
}