Skip to content

Commit

Permalink
fix: push
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed May 4, 2022
1 parent 6df0a6f commit f2fa48b
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import (
"io/fs"
"os"
"strings"
"sync"
"unicode"
"unsafe"

"github.com/FloatTech/zbputils/process"
"github.com/fumiama/go-registry"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
)
Expand Down Expand Up @@ -46,26 +44,24 @@ func main() {
if err != nil {
panic(err)
}
defer r.Close()
var wg sync.WaitGroup
wg.Add(len(files))
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 {
break
}
if c >= 4 {
panic("ERROR:" + err.Error() + "max retry times exceeded")
} else {
fmt.Println("ERROR:", err, ", retry times:", c)
}
process.SleepAbout1sTo2s()
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 {
break
}
}(i, fn)
if c >= 4 {
panic("ERROR:" + err.Error() + "max retry times exceeded")
} else {
fmt.Println("ERROR:", err, ", retry times:", c)
}
_ = r.Close()
err = r.Connect()
if err != nil {
panic(err)
}
}
}
wg.Wait()
_ = r.Close()
}

0 comments on commit f2fa48b

Please sign in to comment.