From 91fa0eb9d7b8c1bb5afac9d68161cf95ae0a02f8 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 24 Feb 2023 18:23:13 +0800 Subject: 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 --- models/avatars/avatar.go | 4 ++-- models/avatars/avatar_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'models/avatars') 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) } -- cgit v1.2.3