From fcc6a677a54e143596efc31494edfcba5ac1eb1c Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 15 Jan 2018 12:13:25 +0000 Subject: [PATCH] lib/upgrade: Always return latest version, even if older than current (fixes #4654) The only special check remaining is the one to prefer a minor upgrade over a major one. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4672 --- lib/upgrade/upgrade_supported.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/upgrade/upgrade_supported.go b/lib/upgrade/upgrade_supported.go index e73432ff..d9b19a35 100644 --- a/lib/upgrade/upgrade_supported.go +++ b/lib/upgrade/upgrade_supported.go @@ -134,34 +134,25 @@ func SelectLatestRelease(rels []Release, current string, upgradeToPreReleases bo var selected Release for _, rel := range rels { - switch CompareVersions(rel.Tag, current) { - case Older, MajorOlder: - // This is older than what we're already running - continue - - case MajorNewer: + if CompareVersions(rel.Tag, current) == MajorNewer { // We've found a new major version. That's fine, but if we've // already found a minor upgrade that is acceptable we should go // with that one first and then revisit in the future. if selected.Tag != "" && CompareVersions(selected.Tag, current) == Newer { return selected, nil } - // else it may be viable, do the needful below - - default: - // New minor release, do the usual processing } if rel.Prerelease && !upgradeToPreReleases { + l.Debugln("skipping pre-release", rel.Tag) continue } for _, asset := range rel.Assets { assetName := path.Base(asset.Name) // Check for the architecture expectedRelease := releaseName(rel.Tag) - l.Debugf("expected release asset %q", expectedRelease) - l.Debugln("considering release", assetName) if strings.HasPrefix(assetName, expectedRelease) { + l.Debugln("selected", rel.Tag) selected = rel } }