From 6188185b22621d16d5d98dea5c5fa3849904b7e5 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Thu, 24 Jul 2014 14:23:25 +0200 Subject: [PATCH] Beta versions *should* upgrade to other beta version (ref #436) --- cmd/syncthing/upgrade_supported.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/cmd/syncthing/upgrade_supported.go b/cmd/syncthing/upgrade_supported.go index e1cd2c974..63efd6dc7 100644 --- a/cmd/syncthing/upgrade_supported.go +++ b/cmd/syncthing/upgrade_supported.go @@ -93,13 +93,24 @@ func currentRelease() (githubRelease, error) { json.NewDecoder(resp.Body).Decode(&rels) resp.Body.Close() - for _, rel := range rels { - if !rel.Prerelease { - return rel, nil + if strings.Contains(Version, "-beta") { + // We are a beta version. Use whatever we can find that is newer-or-equal than current. + for _, rel := range rels { + if compareVersions(rel.Tag, Version) >= 0 { + return rel, nil + } } + // We found nothing. Return the latest release and let the next layer decide. + return rels[0], nil + } else { + // We are a regular release. Only consider non-prerelease versions for upgrade. + for _, rel := range rels { + if !rel.Prerelease { + return rel, nil + } + } + return githubRelease{}, errors.New("no suitable release found") } - - return githubRelease{}, errors.New("no suitable release found") } func readTarGZ(url string, dir string) (string, error) {