mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-03 07:12:27 +00:00
Don't consider prereleases for -upgrade (fixes #436)
This commit is contained in:
parent
58cc108c0c
commit
6065b6cb93
@ -27,9 +27,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type githubRelease struct {
|
type githubRelease struct {
|
||||||
Tag string `json:"tag_name"`
|
Tag string `json:"tag_name"`
|
||||||
Prelease bool `json:"prerelease"`
|
Prerelease bool `json:"prerelease"`
|
||||||
Assets []githubAsset `json:"assets"`
|
Assets []githubAsset `json:"assets"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type githubAsset struct {
|
type githubAsset struct {
|
||||||
@ -49,7 +49,7 @@ func upgrade() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -58,10 +58,17 @@ func upgrade() error {
|
|||||||
json.NewDecoder(resp.Body).Decode(&rels)
|
json.NewDecoder(resp.Body).Decode(&rels)
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
|
|
||||||
if len(rels) != 1 {
|
var rel githubRelease
|
||||||
return fmt.Errorf("Unexpected number of releases: %d", len(rels))
|
for _, trel := range rels {
|
||||||
|
if !trel.Prerelease {
|
||||||
|
rel = trel
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(rel.Tag) == 0 {
|
||||||
|
return errors.New("no suitable release found")
|
||||||
}
|
}
|
||||||
rel := rels[0]
|
|
||||||
|
|
||||||
switch compareVersions(rel.Tag, Version) {
|
switch compareVersions(rel.Tag, Version) {
|
||||||
case -1:
|
case -1:
|
||||||
|
Loading…
Reference in New Issue
Block a user