From de0138d01c670bfb0cb266dd1c1788d306e5ac4a Mon Sep 17 00:00:00 2001 From: cdle Date: Fri, 7 Jul 2023 14:58:30 +0800 Subject: [PATCH] x --- core/init.go | 17 ++++++++++++++--- main.go | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/core/init.go b/core/init.go index 39e76fb..a205dc9 100644 --- a/core/init.go +++ b/core/init.go @@ -19,13 +19,15 @@ import ( ) var DataHome = utils.GetDataHome() +var version = compiled_at func GetVersion() (string, error) { v, e := httplib.Get("http://172.96.255.172:8765/api/version").String() if len(v) == 13 { - sillyGirl.Set("version", v) - if v != compiled_at { - console.Log("发现到更新,版本号:", v) + if version != v && v != compiled_at { + sillyGirl.Set("version", v) + console.Log("发现更新,版本号", v) + version = v } return v, e } @@ -33,6 +35,15 @@ func GetVersion() (string, error) { } func Init() { + go func() { + for { + GetVersion() + if version != compiled_at { + break + } + time.Sleep(time.Minute * 5) + } + }() initLoc() sillyGirl = MakeBucket("sillyGirl") _, err := os.Stat(DataHome) diff --git a/main.go b/main.go index a41187e..0cc12e5 100644 --- a/main.go +++ b/main.go @@ -23,7 +23,7 @@ func main() { if err == nil { app.Set("ip", ip) } - core.GetVersion() + }() core.Init() if app.GetBool("anti_kasi") {