aboutsummaryrefslogtreecommitdiffstats
path: root/models/user_avatar.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-01-03 02:01:09 +0800
committerGitHub <noreply@github.com>2021-01-02 18:01:09 +0000
commit3abea9e9eb8cbe42d1ec0afa70b4941d4066130f (patch)
tree31e2f761d6960f80bb967703ebdbb5fecfcf0071 /models/user_avatar.go
parente6acce649b348cc497b999100a170866a90c87b8 (diff)
downloadgitea-3abea9e9eb8cbe42d1ec0afa70b4941d4066130f.tar.gz
gitea-3abea9e9eb8cbe42d1ec0afa70b4941d4066130f.zip
Fix avatar bugs (#14217)
Diffstat (limited to 'models/user_avatar.go')
-rw-r--r--models/user_avatar.go7
1 files changed, 3 insertions, 4 deletions
diff --git a/models/user_avatar.go b/models/user_avatar.go
index 50c1c99c57..1e9f0e2da4 100644
--- a/models/user_avatar.go
+++ b/models/user_avatar.go
@@ -39,10 +39,9 @@ func (u *User) generateRandomAvatar(e Engine) error {
return fmt.Errorf("RandomImage: %v", err)
}
- if u.Avatar == "" {
- u.Avatar = HashEmail(u.AvatarEmail)
- }
+ u.Avatar = HashEmail(seed)
+ // Don't share the images so that we can delete them easily
if err := storage.SaveFrom(storage.Avatars, u.CustomAvatarRelativePath(), func(w io.Writer) error {
if err := png.Encode(w, img); err != nil {
log.Error("Encode: %v", err)
@@ -132,7 +131,7 @@ func (u *User) UploadAvatar(data []byte) error {
// Otherwise, if any of the users delete his avatar
// Other users will lose their avatars too.
u.Avatar = fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%d-%x", u.ID, md5.Sum(data)))))
- if err = updateUser(sess, u); err != nil {
+ if err = updateUserCols(sess, u, "use_custom_avatar", "avatar"); err != nil {
return fmt.Errorf("updateUser: %v", err)
}