aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-01-21 22:31:11 +0800
committerGitHub <noreply@github.com>2023-01-21 15:31:11 +0100
commiteb793c3361ec86fe8f0344e262073be3791e313d (patch)
treecfcd3097734d44bb6768cd3db925a19e2bf41163 /models
parenta1fcb1cfb84fd6b36c8fe9fd56588119fa4377bc (diff)
downloadgitea-eb793c3361ec86fe8f0344e262073be3791e313d.tar.gz
gitea-eb793c3361ec86fe8f0344e262073be3791e313d.zip
Fix bug on user setting (#22539)
Fix #22537 Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'models')
-rw-r--r--models/user/setting.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/models/user/setting.go b/models/user/setting.go
index f5cfef5b33..aec79b756b 100644
--- a/models/user/setting.go
+++ b/models/user/setting.go
@@ -10,6 +10,7 @@ import (
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/cache"
+ setting_module "code.gitea.io/gitea/modules/setting"
"xorm.io/builder"
)
@@ -154,11 +155,16 @@ func SetUserSetting(userID int64, key, value string) error {
return err
}
- _, err := cache.GetString(genSettingCacheKey(userID, key), func() (string, error) {
- return value, upsertUserSettingValue(userID, key, value)
- })
+ if err := upsertUserSettingValue(userID, key, value); err != nil {
+ 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 {