|
@@ -5,6 +5,7 @@ import (
|
|
|
config "github.com/OliveTin/OliveTin/internal/config"
|
|
config "github.com/OliveTin/OliveTin/internal/config"
|
|
|
"github.com/OliveTin/OliveTin/internal/installationinfo"
|
|
"github.com/OliveTin/OliveTin/internal/installationinfo"
|
|
|
"github.com/robfig/cron/v3"
|
|
"github.com/robfig/cron/v3"
|
|
|
|
|
+ "github.com/Masterminds/semver"
|
|
|
log "github.com/sirupsen/logrus"
|
|
log "github.com/sirupsen/logrus"
|
|
|
"io"
|
|
"io"
|
|
|
"net/http"
|
|
"net/http"
|
|
@@ -55,11 +56,28 @@ func parseVersion(input []byte) string {
|
|
|
if installationinfo.Build.Version == versionMap.Latest {
|
|
if installationinfo.Build.Version == versionMap.Latest {
|
|
|
return "none"
|
|
return "none"
|
|
|
} else {
|
|
} else {
|
|
|
- return versionMap.Latest
|
|
|
|
|
|
|
+ return parseIfVersionIsLater(installationinfo.Build.Version, versionMap.Latest)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func parseIfVersionIsLater(currentString string, latestString string) string {
|
|
|
|
|
+ currentVersion, errCurrent := semver.NewVersion(currentString)
|
|
|
|
|
+ latestVersion, errLatest := semver.NewVersion(latestString)
|
|
|
|
|
+
|
|
|
|
|
+ if errCurrent != nil || errLatest != nil {
|
|
|
|
|
+ log.Warnf("Version parse failure: %v %v", errCurrent, errLatest)
|
|
|
|
|
+
|
|
|
|
|
+ return "version-parse-failure"
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if latestVersion.GreaterThan(currentVersion) {
|
|
|
|
|
+ return latestString
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return "none"
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func doRequest() string {
|
|
func doRequest() string {
|
|
|
req, err := http.NewRequest("GET", "http://update-check.olivetin.app/versions.json", nil)
|
|
req, err := http.NewRequest("GET", "http://update-check.olivetin.app/versions.json", nil)
|
|
|
|
|
|