From 50b189ebad992b59c90918694a3dce6525d6fcaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 17 Apr 2022 16:10:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=B9=E4=B8=BA=E5=B9=B6=E8=A1=8C?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index afd2391..f151ec8 100644 --- a/main.go +++ b/main.go @@ -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() - err = r.Set("data/"+fn, md5s[i]) - fmt.Println("set", "data/"+fn, "=", hex.EncodeToString(helper.StringToBytes(md5s[i]))) - if err != nil { - panic(err) + 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() } }(i, fn) }