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

Merge pull request #4 from FloatTech/main

合并
This commit is contained in:
himawari 2022-04-23 15:51:08 +08:00 committed by GitHub
commit 2a2fbf8e26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

28
main.go
View File

@ -10,9 +10,11 @@ import (
"io/fs" "io/fs"
"os" "os"
"strings" "strings"
"sync"
"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"
) )
@ -44,12 +46,26 @@ func main() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
defer r.Close()
var wg sync.WaitGroup
wg.Add(len(files))
for i, fn := range files { for i, fn := range files {
fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i]))) go func(i int, fn string) {
err = r.Set("data/"+fn, md5s[i]) defer wg.Done()
if err != nil { for c := 0; c < 5; c++ {
panic(err) err = r.Set("data/"+fn, md5s[i])
} fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i])))
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)
} }
r.Close() wg.Wait()
} }