refactor: deprecate int32 (#7025)

* refactor: deprecate int32

* fix(db): reject legacy user quota schemas at startup

* fix(quota): enforce wallet bounds and saturating billing conversions

* fix(rate-limit): keep count*duration from wrapping int64

* fix: error message
This commit is contained in:
Seefs
2026-08-26 20:57:54 +08:00
committed by GitHub
parent 2d8e50bf36
commit a073f74b38
35 changed files with 445 additions and 116 deletions
+16 -3
View File
@@ -2,6 +2,8 @@ package model
import (
"errors"
"fmt"
"math"
"sync"
"time"
@@ -42,11 +44,22 @@ func InitBatchUpdater() {
func addNewRecord(type_ int, id int, value int) {
batchUpdateLocks[type_].Lock()
defer batchUpdateLocks[type_].Unlock()
if _, ok := batchUpdateStores[type_][id]; !ok {
old, ok := batchUpdateStores[type_][id]
if !ok {
batchUpdateStores[type_][id] = value
} else {
batchUpdateStores[type_][id] += value
return
}
sum := old + value
if (value > 0 && sum < old) || (value < 0 && sum > old) {
common.SysError(fmt.Sprintf("batch update overflow: type=%d id=%d old=%d value=%d", type_, id, old, value))
if value > 0 {
sum = math.MaxInt
} else {
sum = math.MinInt
}
}
batchUpdateStores[type_][id] = sum
}
func batchUpdate() {