优化同时校验搜索和发现的提示逻辑

纯发现源(搜索链接为空) 跳过校验搜索
搜索链接不为空 搜索失效时最终校验提示失败
pull/1568/head
Xwite 3 years ago
parent 27bc4787e3
commit 515120c3a3
  1. 7
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  2. 8
      app/src/main/java/io/legado/app/service/CheckSourceService.kt

@ -134,6 +134,13 @@ data class BookSource(
return this return this
} }
fun hasGroup(group: String): Boolean {
bookSourceGroup?.splitNotBlank(AppPattern.splitGroupRegex)?.toHashSet()?.let {
return if (it.indexOf(group) != -1) true else false
}
return false
}
fun equal(source: BookSource) = fun equal(source: BookSource) =
equal(bookSourceName, source.bookSourceName) equal(bookSourceName, source.bookSourceName)
&& equal(bookSourceUrl, source.bookSourceUrl) && equal(bookSourceUrl, source.bookSourceUrl)

@ -121,8 +121,8 @@ class CheckSourceService : BaseService() {
searchWord = it searchWord = it
} }
} }
//校验搜索 //校验搜索 用户设置校验搜索 并且 搜索链接不为空
if (CheckSource.checkSearch) { if (CheckSource.checkSearch && !source.searchUrl.isNullOrBlank()) {
books = WebBook.searchBookAwait(this, source, searchWord) books = WebBook.searchBookAwait(this, source, searchWord)
if (books.isEmpty()) source.addGroup("搜索失效") else source.removeGroup("搜索失效") if (books.isEmpty()) source.addGroup("搜索失效") else source.removeGroup("搜索失效")
} }
@ -187,7 +187,11 @@ class CheckSourceService : BaseService() {
?.filterNot { ?.filterNot {
it.startsWith("Error: ") it.startsWith("Error: ")
}?.joinToString("\n") }?.joinToString("\n")
if (source.hasGroup("搜索失效")) {
Debug.updateFinalMessage(source.bookSourceUrl, "失败")
} else {
Debug.updateFinalMessage(source.bookSourceUrl, "成功") Debug.updateFinalMessage(source.bookSourceUrl, "成功")
}
}.onFinally(searchCoroutine) { }.onFinally(searchCoroutine) {
source.respondTime = Debug.getRespondTime(source.bookSourceUrl) source.respondTime = Debug.getRespondTime(source.bookSourceUrl)
appDb.bookSourceDao.update(source) appDb.bookSourceDao.update(source)

Loading…
Cancel
Save