fix: prefer Gitea download URL when versions equal (China-reachable)

Same-version update was picking GitHub URL (crowded first) which
downloads fail in China. Now Gitea info is inserted before GitHub
so maxByOrNull takes the Gitea one on version tie.

version 1.9.0 -> 1.9.1 (code 29 -> 30)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-10 14:35:59 +08:00
parent 0ea5e1b228
commit b14ee02ef8
2 changed files with 6 additions and 5 deletions
@@ -69,13 +69,14 @@ class UpdateChecker(private val context: Context) {
if (throttle && now - settings.lastUpdateCheckTime.value < CHECK_INTERVAL_MS) return@runCatching updateInfo.value
// 先查 GitHub(公开默认源),从其 release notes 动态发现额外源(如自建 Gitea),取最高版本
// 同版本时 Gitea 优先(国内可达,GitHub 可能被墙导致下载失败)
val infos = mutableListOf<UpdateInfo>()
val gh = runCatching { fetchRelease(GITHUB_API) }.getOrNull()
if (gh != null) {
val giteaInfo = parseUpdateSource(gh.releaseNotes)?.let { runCatching { fetchRelease(it) }.getOrNull() }
// Gitea 放前面,同版本时优先用它下载(国内可达)
if (giteaInfo != null) infos.add(giteaInfo)
infos.add(gh)
parseUpdateSource(gh.releaseNotes)?.let { src ->
runCatching { fetchRelease(src) }.getOrNull()?.let { infos.add(it) }
}
}
settings.setLastUpdateCheck(now)
if (infos.isEmpty()) {