From 5f45fb6aae8949c19504ce0871006cb3d90155ba Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Wed, 1 Feb 2023 10:18:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=99=E5=85=A5Agent=20IP=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E6=8F=90=E7=A4=BAid=E9=87=8D=E5=A4=8D=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/utils/agents/db.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/utils/agents/db.go b/internal/utils/agents/db.go index c721af4..5798f33 100644 --- a/internal/utils/agents/db.go +++ b/internal/utils/agents/db.go @@ -13,6 +13,7 @@ import ( "log" "os" "path/filepath" + "strings" ) const ( @@ -94,9 +95,13 @@ func (this *DB) InsertAgentIP(ipId int64, ip string, agentCode string) error { return errors.New("db should not be nil") } - this.log("InsertAgentIP", "id:", ipId, "ip:", ip, "agent:", agentCode) _, err := this.insertAgentIPStmt.Exec(ipId, ip, agentCode) if err != nil { + // 不提示ID重复错误 + if strings.Contains(err.Error(), "UNIQUE constraint") { + return nil + } + return err }