Skip to content

Commit

Permalink
修复cfw删库导致updater无法更新的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Nov 3, 2023
1 parent 70d55a0 commit 27555a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 5 additions & 1 deletion data.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const (
MacDmg
)

var cfwVersionList []string

type cfwInfo struct {
rootPath, mixPort, version string
portableData bool
Expand Down Expand Up @@ -222,9 +224,11 @@ func cfwInput() {
}

func cfwSelect() {
fmt.Println("正在获取cfw最新的版本号..")
cfwVersionList = recentlyTag(fmt.Sprintf("https://github.com/%s/tags", CfwRepos))
cfwInput()
// 通过github tag页面是否为404来判断tag是否存在
searchText := webSearch("https://github.com/Fndroid/clash_for_windows_pkg/releases/tag/"+cfwVersion, "This is not the web page you are looking for")
searchText := webSearch(fmt.Sprintf("https://github.com/%s/releases/tag/%s", CfwRepos, cfwVersion), "This is not the web page you are looking for")
if searchText != "" {
exit(fmt.Sprintf("cfw %s 版本不存在!", cfwVersion))
}
Expand Down
7 changes: 3 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import (
var (
version, buildDate, goVersion, gitVersion string
cfwVersion, tempPath, transWay string
cfwVersionList []string
updateTrans bool
updateCore = true
ci *cfwInfo
v = flag.Bool("v", false, "显示版本号")
forceUpdate = flag.Bool("f", false, "强制更新cfw(默认和已存在版本相同则不更新)")
)

const CfwRepos = "Fndroid/clash_for_windows_pkg"

func init() {
flag.Parse()
if *forceUpdate {
Expand Down Expand Up @@ -48,7 +49,7 @@ func getCfw() *downloadInfo {
} else {
cfwFileName = fmt.Sprintf("Clash.for.Windows-%s-win.7z", cfwVersion)
}
cfwUrl := fmt.Sprintf("https://github.com/Fndroid/clash_for_windows_pkg/releases/download/%s/%s", cfwVersion, cfwFileName)
cfwUrl := fmt.Sprintf("https://github.com/%s/releases/download/%s/%s", CfwRepos, cfwVersion, cfwFileName)
downloadFile(cfwUrl, "")
di := newDI(cfwUrl)
if ci.installType == Win7z {
Expand Down Expand Up @@ -95,8 +96,6 @@ func checkEnv() {
proxyUrl := fmt.Sprintf("127.0.0.1:%s", ci.mixPort)
os.Setenv("HTTP_PROXY", proxyUrl)
os.Setenv("HTTPS_PROXY", proxyUrl)
fmt.Println("正在获取cfw最新的版本号..")
cfwVersionList = recentlyTag("https://github.com/Fndroid/clash_for_windows_pkg/tags")
updateUpdater()
cfwSelect()
tranSelect()
Expand Down

0 comments on commit 27555a3

Please sign in to comment.