feat: skip GetUserCount() if there is no quota limit (#3491)

This commit is contained in:
DacongDA 2025-01-10 22:28:25 +08:00 committed by GitHub
parent fcfb73af6e
commit b96fa2a995
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 9 deletions

View File

@ -353,13 +353,7 @@ func (c *ApiController) AddUser() {
return
}
count, err := object.GetUserCount("", "", "", "")
if err != nil {
c.ResponseError(err.Error())
return
}
if err := checkQuotaForUser(int(count)); err != nil {
if err := checkQuotaForUser(); err != nil {
c.ResponseError(err.Error())
return
}

View File

@ -294,12 +294,18 @@ func checkQuotaForProvider(count int) error {
return nil
}
func checkQuotaForUser(count int) error {
func checkQuotaForUser() error {
quota := conf.GetConfigQuota().User
if quota == -1 {
return nil
}
if count >= quota {
count, err := object.GetUserCount("", "", "", "")
if err != nil {
return err
}
if int(count) >= quota {
return fmt.Errorf("user quota is exceeded")
}
return nil