mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 06:03:51 +03:00
Fix bug on user setting (#22539)
Fix #22537 Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
This commit is contained in:
parent
a1fcb1cfb8
commit
eb793c3361
1 changed files with 10 additions and 4 deletions
|
@ -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,13 +155,18 @@ 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
|
||||
}
|
||||
|
||||
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 {
|
||||
return db.WithTx(db.DefaultContext, func(ctx context.Context) error {
|
||||
e := db.GetEngine(ctx)
|
||||
|
|
Loading…
Reference in a new issue