From 0712a80ea049db3863d5a76005b5850d4b59c5af Mon Sep 17 00:00:00 2001 From: fumiama Date: Mon, 13 Dec 2021 21:06:11 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=20=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=97=B6=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/file/updater.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/utils/file/updater.go b/utils/file/updater.go index 6570a380..88224521 100644 --- a/utils/file/updater.go +++ b/utils/file/updater.go @@ -7,6 +7,7 @@ import ( "io" "net/http" "os" + "sync" "unsafe" reg "github.com/fumiama/go-registry" @@ -19,6 +20,7 @@ const ( var ( registry = reg.NewRegReader("reilia.eastasia.azurecontainer.io:32664", "fumiama") + lzmu sync.Mutex ) func GetLazyData(path string, isReturnDataBytes, isDataMustEqual bool) ([]byte, error) { @@ -29,6 +31,7 @@ func GetLazyData(path string, isReturnDataBytes, isDataMustEqual bool) ([]byte, logrus.Infoln("[file]检查懒加载文件:", path) u := dataurl + path + lzmu.Lock() err := registry.Connect() if err != nil { logrus.Errorln("[file]无法连接到md5验证服务器,请自行确保下载文件的正确性:", err) @@ -42,6 +45,7 @@ func GetLazyData(path string, isReturnDataBytes, isDataMustEqual bool) ([]byte, _ = registry.Close() } } + lzmu.Unlock() if IsExist(path) { data, err = os.ReadFile(path)