diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-02-24 18:23:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-24 18:23:13 +0800 |
commit | 91fa0eb9d7b8c1bb5afac9d68161cf95ae0a02f8 (patch) | |
tree | e2e552ec7ec356af752411d8b595e81c1d28ed24 /models/avatars | |
parent | edf98a2dc30956c8e04b778bb7f1ce55c14ba963 (diff) | |
download | gitea-91fa0eb9d7b8c1bb5afac9d68161cf95ae0a02f8.tar.gz gitea-91fa0eb9d7b8c1bb5afac9d68161cf95ae0a02f8.zip |
Avoid warning for system setting when start up (#23054)
Partially fix #23050
After #22294 merged, it always has a warning log like `cannot get
context cache` when starting up. This should not affect any real life
but it's annoying. This PR will fix the problem. That means when
starting up, getting the system settings will not try from the cache but
will read from the database directly.
---------
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'models/avatars')
-rw-r--r-- | models/avatars/avatar.go | 4 | ||||
-rw-r--r-- | models/avatars/avatar_test.go | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/models/avatars/avatar.go b/models/avatars/avatar.go index 6cf05dd284..265ee6428e 100644 --- a/models/avatars/avatar.go +++ b/models/avatars/avatar.go @@ -153,7 +153,7 @@ func generateEmailAvatarLink(ctx context.Context, email string, size int, final return DefaultAvatarLink() } - enableFederatedAvatar := system_model.GetSettingBool(ctx, system_model.KeyPictureEnableFederatedAvatar) + enableFederatedAvatar := system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureEnableFederatedAvatar) var err error if enableFederatedAvatar && system_model.LibravatarService != nil { @@ -174,7 +174,7 @@ func generateEmailAvatarLink(ctx context.Context, email string, size int, final return urlStr } - disableGravatar := system_model.GetSettingBool(ctx, system_model.KeyPictureDisableGravatar) + disableGravatar := system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar) if !disableGravatar { // copy GravatarSourceURL, because we will modify its Path. avatarURLCopy := *system_model.GravatarSourceURL diff --git a/models/avatars/avatar_test.go b/models/avatars/avatar_test.go index a3cb36d0e1..59daaeb669 100644 --- a/models/avatars/avatar_test.go +++ b/models/avatars/avatar_test.go @@ -28,7 +28,7 @@ func enableGravatar(t *testing.T) { err := system_model.SetSettingNoVersion(db.DefaultContext, system_model.KeyPictureDisableGravatar, "false") assert.NoError(t, err) setting.GravatarSource = gravatarSource - err = system_model.Init() + err = system_model.Init(db.DefaultContext) assert.NoError(t, err) } |