Feat: use database transactions to delete / update file size

This commit is contained in:
HFO4
2022-02-27 14:23:26 +08:00
parent 2811ee3285
commit 285e80ba76
6 changed files with 77 additions and 39 deletions

View File

@@ -89,6 +89,11 @@ func (user *User) IncreaseStorage(size uint64) bool {
return false
}
// ChangeStorage 更新用户容量
func (user *User) ChangeStorage(tx *gorm.DB, operator string, size uint64) error {
return tx.Model(user).Update("storage", gorm.Expr("storage "+operator+" ?", size)).Error
}
// IncreaseStorageWithoutCheck 忽略可用容量,增加用户已用容量
func (user *User) IncreaseStorageWithoutCheck(size uint64) {
if size == 0 {