From 1c3d712fe79357b5f486c84977a361357547f51d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Codru=C8=9B=20Constantin=20Gu=C8=99oi?= Date: Wed, 14 Feb 2018 21:37:35 +0000 Subject: [PATCH] Fixes missing avatars in offline mode (#3471) (#3477) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Codruț Constantin Gușoi --- models/user.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/models/user.go b/models/user.go index bf2868328..8f2ec547c 100644 --- a/models/user.go +++ b/models/user.go @@ -299,7 +299,9 @@ func (u *User) generateRandomAvatar(e Engine) error { } // NOTICE for random avatar, it still uses id as avatar name, but custom avatar use md5 // since random image is not a user's photo, there is no security for enumable - u.Avatar = fmt.Sprintf("%d", u.ID) + if u.Avatar == "" { + u.Avatar = fmt.Sprintf("%d", u.ID) + } if err = os.MkdirAll(filepath.Dir(u.CustomAvatarPath()), os.ModePerm); err != nil { return fmt.Errorf("MkdirAll: %v", err) }