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:
@@ -13,8 +13,8 @@ android {
|
||||
applicationId = "com.a2i.forwarder"
|
||||
minSdk = 34
|
||||
targetSdk = 36
|
||||
versionCode = 28
|
||||
versionName = "1.8.11"
|
||||
versionCode = 29
|
||||
versionName = "1.9.0"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user