feat: truncate abilities table before processing channels
This commit is contained in:
@@ -284,9 +284,24 @@ func FixAbility() (int, int, error) {
|
|||||||
return 0, 0, errors.New("已经有一个修复任务在运行中,请稍后再试")
|
return 0, 0, errors.New("已经有一个修复任务在运行中,请稍后再试")
|
||||||
}
|
}
|
||||||
defer fixLock.Unlock()
|
defer fixLock.Unlock()
|
||||||
|
|
||||||
|
// truncate abilities table
|
||||||
|
if common.UsingSQLite {
|
||||||
|
err := DB.Exec("DELETE FROM abilities").Error
|
||||||
|
if err != nil {
|
||||||
|
common.SysError(fmt.Sprintf("Delete abilities failed: %s", err.Error()))
|
||||||
|
return 0, 0, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
err := DB.Exec("TRUNCATE TABLE abilities").Error
|
||||||
|
if err != nil {
|
||||||
|
common.SysError(fmt.Sprintf("Truncate abilities failed: %s", err.Error()))
|
||||||
|
return 0, 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
var channels []*Channel
|
var channels []*Channel
|
||||||
// Find all channels
|
// Find all channels
|
||||||
err := DB.Model(&Channel{}).Find(&channels).Error
|
err = DB.Model(&Channel{}).Find(&channels).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user