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