cmd/ursrv: Properly sort versions (fixes #6991)

This commit is contained in:
Jakob Borg 2020-09-18 08:11:48 +02:00
parent 9f8b01b1b9
commit 67761d8795

View File

@ -28,6 +28,7 @@ import (
"github.com/oschwald/geoip2-golang" "github.com/oschwald/geoip2-golang"
"github.com/syncthing/syncthing/lib/upgrade"
"github.com/syncthing/syncthing/lib/ur/contract" "github.com/syncthing/syncthing/lib/ur/contract"
) )
@ -978,7 +979,9 @@ func (s *summary) MarshalJSON() ([]byte, error) {
for v := range s.versions { for v := range s.versions {
versions = append(versions, v) versions = append(versions, v)
} }
sort.Strings(versions) sort.Slice(versions, func(a, b int) bool {
return upgrade.CompareVersions(versions[a], versions[b]) < 0
})
var filtered []string var filtered []string
for _, v := range versions { for _, v := range versions {