fix(书源导入):no path $.sourceUrls find
json.read找不到会抛出异常
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user