✏️ 修复 waitgroup 错误

This commit is contained in:
fumiama 2022-01-02 22:12:40 +08:00
parent f0fc5d6598
commit c13641dd1d

View File

@ -11,6 +11,7 @@ import (
"time" "time"
"unsafe" "unsafe"
"github.com/FloatTech/ZeroBot-Plugin/utils/process"
reg "github.com/fumiama/go-registry" reg "github.com/fumiama/go-registry"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -47,24 +48,24 @@ func GetLazyData(path string, isReturnDataBytes, isDataMustEqual bool) ([]byte,
connerr = registry.ConnectIn(time.Second * 4) connerr = registry.ConnectIn(time.Second * 4)
if connerr == nil { if connerr == nil {
isconnected = true isconnected = true
processes.Add(1)
go func() { go func() {
process.SleepAbout1sTo2s()
processes.Wait() processes.Wait()
_ = registry.Close() _ = registry.Close()
isconnected = false isconnected = false
logrus.Infoln("[file]关闭到md5验证服务器的连接")
}() }()
} else { } else {
logrus.Warnln("[file]连接md5验证服务器失败:", connerr) logrus.Warnln("[file]连接md5验证服务器失败:", connerr)
} }
} }
connmu.Unlock() connmu.Unlock()
} else {
processes.Add(1)
} }
if connerr != nil { if connerr != nil {
logrus.Warnln("[file]无法连接到md5验证服务器请自行确保下载文件", path, "的正确性") logrus.Warnln("[file]无法连接到md5验证服务器请自行确保下载文件", path, "的正确性")
} else { } else {
processes.Add(1)
getmu.Lock() getmu.Lock()
ms, err = registry.Get(path) ms, err = registry.Get(path)
getmu.Unlock() getmu.Unlock()