Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
fixed version checking
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsMePepijn committed Nov 1, 2023
1 parent 0cf4863 commit a68a0f4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.18

require (
github.com/adrg/xdg v0.4.0
github.com/hashicorp/go-version v1.6.0
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf
github.com/jensvandewiel/gosteamcmd v0.1.2
github.com/sethvargo/go-password v0.2.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7VjIE6z8dIvMsI4/s+1qr5EL+zoIGev1BQj1eoJ8=
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
Expand Down
18 changes: 16 additions & 2 deletions helpers/updateServiceHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"slices"
"strings"

"github.com/hashicorp/go-version"
"github.com/inconshreveable/go-update"
"github.com/sqweek/dialog"
)
Expand Down Expand Up @@ -65,7 +66,7 @@ func CheckForUpdates(WailsConfigFile []byte) {
println("Skipping update check")
return
}

resBody, err := io.ReadAll(res.Body)
if err != nil {
fmt.Printf("server: could not read request body: %s\n", err)
Expand All @@ -85,7 +86,20 @@ func CheckForUpdates(WailsConfigFile []byte) {
release.TagName = nameArr[len(nameArr)-1]
}

if release.TagName <= cf.Version {
installedVersion, err := version.NewVersion(cf.Version)
if err != nil {
fmt.Printf("Error: Could not parse installed version: %s\n", err)
println("Skipping update check")
return
}
latestVersion, err := version.NewVersion(release.TagName)
if err != nil {
fmt.Printf("Error: Could not parse latest version: %s\n", err)
println("Skipping update check")
return
}

if installedVersion.GreaterThanOrEqual(latestVersion) {
fmt.Printf("Already on atest release: %s\n", release.Name)
return
}
Expand Down

0 comments on commit a68a0f4

Please sign in to comment.