perf: 优化更新策略

This commit is contained in:
lisonge 2024-01-28 22:59:30 +08:00
parent a85966c6dd
commit 1fb3248850
2 changed files with 11 additions and 5 deletions

View File

@ -326,7 +326,7 @@ class GkdAbService : CompositionAbService({
}
}
val newSubsRaw = RawSubscription.parse(
client.get(subsItem.updateUrl).bodyAsText()
client.get(oldSubsRaw?.updateUrl ?: subsItem.updateUrl).bodyAsText()
)
if (newSubsRaw.id != subsItem.id) {
return@forEach
@ -336,7 +336,6 @@ class GkdAbService : CompositionAbService({
}
updateSubscription(newSubsRaw)
val newItem = subsItem.copy(
updateUrl = newSubsRaw.updateUrl ?: subsItem.updateUrl,
mtime = System.currentTimeMillis()
)
DbSet.subsItemDao.update(newItem)

View File

@ -95,7 +95,11 @@ class SubsManageVm @Inject constructor() : ViewModel() {
val subsVersion =
client.get(oldSubsRaw.checkUpdateUrl).body<SubsVersion>()
LogUtils.d("快速检测更新成功", subsVersion)
if (subsVersion.id == oldSubsRaw.id && subsVersion.version <= oldSubsRaw.version) {
if (subsVersion.id != oldSubsRaw.id) {
toast("${oldItem.id}:checkUpdateUrl获取id不一致")
return@mapNotNull null
}
if (subsVersion.version <= oldSubsRaw.version) {
return@mapNotNull null
}
} catch (e: Exception) {
@ -103,13 +107,16 @@ class SubsManageVm @Inject constructor() : ViewModel() {
}
}
val newSubsRaw = RawSubscription.parse(
client.get(oldItem.updateUrl).bodyAsText()
client.get(oldSubsRaw?.updateUrl ?: oldItem.updateUrl).bodyAsText()
)
if (newSubsRaw.id != oldItem.id) {
toast("${oldItem.id}:updateUrl获取id不一致")
return@mapNotNull null
}
if (oldSubsRaw != null && newSubsRaw.version <= oldSubsRaw.version) {
return@mapNotNull null
}
val newItem = oldItem.copy(
updateUrl = newSubsRaw.updateUrl ?: oldItem.updateUrl,
mtime = System.currentTimeMillis(),
)
updateSubscription(newSubsRaw)