Skip to content

Commit

Permalink
feat: Allow upgrade to latest release (#1235)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed Apr 30, 2024
1 parent 314c0bb commit 107e3e7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions hub/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"time"

mihomoHttp "github.com/metacubex/mihomo/component/http"
"github.com/metacubex/mihomo/constant"
C "github.com/metacubex/mihomo/constant"
"github.com/metacubex/mihomo/log"

Expand Down Expand Up @@ -52,6 +51,10 @@ func init() {
if runtime.GOARCH == "amd64" && cpuid.CPU.X64Level() < 3 {
amd64Compatible = "-compatible"
}
if !strings.HasPrefix(C.Version, "alpha") {
baseURL = "https://github.com/MetaCubeX/mihomo/releases/latest/download/mihomo"
versionURL = "https://github.com/MetaCubeX/mihomo/releases/latest/download/version.txt"
}
}

type updateError struct {
Expand All @@ -73,9 +76,9 @@ func Update(execPath string) (err error) {
return err
}

log.Infoln("current version %s, latest version %s", constant.Version, latestVersion)
log.Infoln("current version %s, latest version %s", C.Version, latestVersion)

if latestVersion == constant.Version {
if latestVersion == C.Version {
err := &updateError{Message: "already using latest version"}
return err
}
Expand Down

0 comments on commit 107e3e7

Please sign in to comment.