Skip to content

Commit

Permalink
fix: restart after self-update
Browse files Browse the repository at this point in the history
  • Loading branch information
anfragment committed Dec 4, 2023
1 parent 1f1cc07 commit e52a370
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions config/selfupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package config
import (
"context"
"log"
"os"
"os/exec"

"github.com/blang/semver"
"github.com/rhysd/go-github-selfupdate/selfupdate"
Expand Down Expand Up @@ -35,7 +37,7 @@ func SelfUpdate(ctx context.Context) {
return
}

v := semver.MustParse(Version)
v, _ := semver.ParseTolerant(Version)
_, err = selfupdate.UpdateSelf(v, "anfragment/zen")
if err != nil {
log.Printf("error occurred while updating binary: %v", err)
Expand All @@ -54,7 +56,12 @@ func SelfUpdate(ctx context.Context) {
log.Printf("error occurred while showing restart dialog: %v", err)
}
if action == "Yes" {
runtime.WindowReloadApp(ctx)
cmd := exec.Command(os.Args[0], os.Args[1:]...)
if err := cmd.Start(); err != nil {
log.Printf("error occurred while restarting: %v", err)
return
}
runtime.Quit(ctx)
}
}

Expand Down

0 comments on commit e52a370

Please sign in to comment.