1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-04 08:17:24 -05:00

Fix bug on user setting (#22539)

Fix #22537

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
This commit is contained in:
Lunny Xiao 2023-01-21 22:31:11 +08:00 committed by GitHub
parent a1fcb1cfb8
commit eb793c3361
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ import (
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/cache" "code.gitea.io/gitea/modules/cache"
setting_module "code.gitea.io/gitea/modules/setting"
"xorm.io/builder" "xorm.io/builder"
) )
@ -154,11 +155,16 @@ func SetUserSetting(userID int64, key, value string) error {
return err return err
} }
_, err := cache.GetString(genSettingCacheKey(userID, key), func() (string, error) { if err := upsertUserSettingValue(userID, key, value); err != nil {
return value, upsertUserSettingValue(userID, key, value)
})
return err return err
}
cc := cache.GetCache()
if cc != nil {
return cc.Put(genSettingCacheKey(userID, key), value, setting_module.CacheService.TTLSeconds())
}
return nil
} }
func upsertUserSettingValue(userID int64, key, value string) error { func upsertUserSettingValue(userID int64, key, value string) error {