diff --git a/cmd/syncthing/upgrade_common.go b/cmd/syncthing/upgrade_common.go index 4cd3523e3..0d48b1402 100644 --- a/cmd/syncthing/upgrade_common.go +++ b/cmd/syncthing/upgrade_common.go @@ -7,9 +7,9 @@ import ( ) type githubRelease struct { - Tag string `json:"tag_name"` - Prelease bool `json:"prerelease"` - Assets []githubAsset `json:"assets"` + Tag string `json:"tag_name"` + Prerelease bool `json:"prerelease"` + Assets []githubAsset `json:"assets"` } type githubAsset struct { diff --git a/cmd/syncthing/upgrade_supported.go b/cmd/syncthing/upgrade_supported.go index 63a84f972..e1cd2c974 100644 --- a/cmd/syncthing/upgrade_supported.go +++ b/cmd/syncthing/upgrade_supported.go @@ -84,7 +84,7 @@ func upgrade() error { } func currentRelease() (githubRelease, error) { - resp, err := http.Get("https://api.github.com/repos/calmh/syncthing/releases?per_page=1") + resp, err := http.Get("https://api.github.com/repos/calmh/syncthing/releases?per_page=10") if err != nil { return githubRelease{}, err } @@ -93,10 +93,13 @@ func currentRelease() (githubRelease, error) { json.NewDecoder(resp.Body).Decode(&rels) resp.Body.Close() - if len(rels) != 1 { - return githubRelease{}, fmt.Errorf("Unexpected number of releases: %d", len(rels)) + for _, rel := range rels { + if !rel.Prerelease { + return rel, nil + } } - return rels[0], nil + + return githubRelease{}, errors.New("no suitable release found") } func readTarGZ(url string, dir string) (string, error) {