Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug on user setting #22539

Merged
merged 3 commits into from
Jan 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions models/user/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down