1
0
mirror of https://github.com/FloatTech/zbpdata.git synced 2025-04-22 04:02:10 +09:00

feat: 改为并行上传

This commit is contained in:
源文雨 2022-04-17 16:10:37 +08:00
parent ab10aa8a6b
commit 50b189ebad

13
main.go
View File

@ -14,6 +14,7 @@ import (
"unicode" "unicode"
"unsafe" "unsafe"
"github.com/FloatTech/zbputils/process"
"github.com/fumiama/go-registry" "github.com/fumiama/go-registry"
"github.com/wdvxdr1123/ZeroBot/utils/helper" "github.com/wdvxdr1123/ZeroBot/utils/helper"
) )
@ -51,10 +52,18 @@ func main() {
for i, fn := range files { for i, fn := range files {
go func(i int, fn string) { go func(i int, fn string) {
defer wg.Done() defer wg.Done()
for c := 0; c < 5; c++ {
err = r.Set("data/"+fn, md5s[i]) err = r.Set("data/"+fn, md5s[i])
fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i]))) fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i])))
if err != nil { if err == nil {
panic(err) break
}
if c >= 4 {
panic("ERROR:" + err.Error() + "max retry times exceeded")
} else {
fmt.Println("ERROR:", err, ", retry times:", c)
}
process.SleepAbout1sTo2s()
} }
}(i, fn) }(i, fn)
} }