fix(updater): query every release source and keep the highest version
check_for_updates returned on the first host that answered. Forgejo is listed first, so the updater was pinned to the Forgejo release feed and never looked at GitHub. A release published only on GitHub was invisible: a user running v0.2.17 was told that v0.2.18 was the newest release and was never offered the v0.2.19 onward releases. Both hosts are now queried and the release with the highest version wins, so a lagging mirror can no longer hide a newer release.
This commit is contained in:
parent
3e5de43890
commit
40b05df364
1 changed files with 13 additions and 2 deletions
|
|
@ -61,6 +61,12 @@ pub fn check_for_updates() -> Option<ReleaseInfo> {
|
|||
format!("https://api.github.com/repos/{}/releases/latest", REPO_OWNER_NAME),
|
||||
];
|
||||
|
||||
// Every source is queried and the highest version wins. Returning on the
|
||||
// first answer would pin the updater to whichever host happens to be
|
||||
// listed first, so a release published on the other one would never be
|
||||
// seen.
|
||||
let mut best: Option<ReleaseInfo> = None;
|
||||
|
||||
for url in urls {
|
||||
let mut cmd = std::process::Command::new("curl");
|
||||
cmd.args([
|
||||
|
|
@ -81,7 +87,7 @@ pub fn check_for_updates() -> Option<ReleaseInfo> {
|
|||
let clean_ver = release.tag_name.trim().trim_start_matches('v').to_string();
|
||||
let has_update = is_newer(&clean_ver, CURRENT_VERSION);
|
||||
|
||||
return Some(ReleaseInfo {
|
||||
let info = ReleaseInfo {
|
||||
tag_name: release.tag_name,
|
||||
version: clean_ver,
|
||||
name: release.name.unwrap_or_else(|| format!("v{}", CURRENT_VERSION)),
|
||||
|
|
@ -89,10 +95,15 @@ pub fn check_for_updates() -> Option<ReleaseInfo> {
|
|||
release_notes: release.body.unwrap_or_default(),
|
||||
has_update,
|
||||
assets: release.assets,
|
||||
};
|
||||
|
||||
best = Some(match best {
|
||||
Some(current) if !is_newer(&info.version, ¤t.version) => current,
|
||||
_ => info,
|
||||
});
|
||||
}
|
||||
}
|
||||
None
|
||||
best
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue