mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-08 03:00:26 +08:00
优化代码
This commit is contained in:
@@ -305,7 +305,7 @@ func (this *SQLDump) tryCreateIndex(err error, db *dbs.DB, tableName string, ind
|
||||
}
|
||||
|
||||
// 处理Duplicate entry
|
||||
if strings.Index(err.Error(), "Error 1062: Duplicate entry") >= 0 && (strings.HasSuffix(tableName, "Stats") || strings.HasSuffix(tableName, "Values")) {
|
||||
if strings.Contains(err.Error(), "Error 1062: Duplicate entry") && (strings.HasSuffix(tableName, "Stats") || strings.HasSuffix(tableName, "Values")) {
|
||||
var tries = 5 // 尝试次数
|
||||
for i := 0; i < tries; i++ {
|
||||
_, err = db.Exec("TRUNCATE TABLE " + tableName)
|
||||
|
||||
Reference in New Issue
Block a user