"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "models/user_avatar.go" between
gitea-1.13.1.tar.gz and gitea-1.13.2.tar.gz

About: Gitea allows to set up a self-hosted code hosting Git service (a fork of Gogs).

user_avatar.go  (gitea-1.13.1):user_avatar.go  (gitea-1.13.2)
skipping to change at line 43 skipping to change at line 43
seed := u.Email seed := u.Email
if len(seed) == 0 { if len(seed) == 0 {
seed = u.Name seed = u.Name
} }
img, err := avatar.RandomImage([]byte(seed)) img, err := avatar.RandomImage([]byte(seed))
if err != nil { if err != nil {
return fmt.Errorf("RandomImage: %v", err) return fmt.Errorf("RandomImage: %v", err)
} }
if u.Avatar == "" { u.Avatar = base.HashEmail(seed)
u.Avatar = base.HashEmail(u.AvatarEmail)
}
// 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 := storage.SaveFrom(storage.Avatars, u.CustomAvatarRelativePath(), func(w io.Writer) error {
if err := png.Encode(w, img); err != nil { if err := png.Encode(w, img); err != nil {
log.Error("Encode: %v", err) log.Error("Encode: %v", err)
} }
return err return err
}); err != nil { }); err != nil {
return fmt.Errorf("Failed to create dir %s: %v", u.CustomAvatarRe lativePath(), err) return fmt.Errorf("Failed to create dir %s: %v", u.CustomAvatarRe lativePath(), err)
} }
if _, err := e.ID(u.ID).Cols("avatar").Update(u); err != nil { if _, err := e.ID(u.ID).Cols("avatar").Update(u); err != nil {
skipping to change at line 136 skipping to change at line 135
if err = sess.Begin(); err != nil { if err = sess.Begin(); err != nil {
return err return err
} }
u.UseCustomAvatar = true u.UseCustomAvatar = true
// Different users can upload same image as avatar // Different users can upload same image as avatar
// If we prefix it with u.ID, it will be separated // If we prefix it with u.ID, it will be separated
// Otherwise, if any of the users delete his avatar // Otherwise, if any of the users delete his avatar
// Other users will lose their avatars too. // Other users will lose their avatars too.
u.Avatar = fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%d-%x", u.ID, md 5.Sum(data))))) u.Avatar = fmt.Sprintf("%x", md5.Sum([]byte(fmt.Sprintf("%d-%x", u.ID, md 5.Sum(data)))))
if err = updateUser(sess, u); err != nil { if err = updateUserCols(sess, u, "use_custom_avatar", "avatar"); err != n il {
return fmt.Errorf("updateUser: %v", err) return fmt.Errorf("updateUser: %v", err)
} }
if err := storage.SaveFrom(storage.Avatars, u.CustomAvatarRelativePath(), func(w io.Writer) error { if err := storage.SaveFrom(storage.Avatars, u.CustomAvatarRelativePath(), func(w io.Writer) error {
if err := png.Encode(w, *m); err != nil { if err := png.Encode(w, *m); err != nil {
log.Error("Encode: %v", err) log.Error("Encode: %v", err)
} }
return err return err
}); err != nil { }); err != nil {
return fmt.Errorf("Failed to create dir %s: %v", u.CustomAvatarRe lativePath(), err) return fmt.Errorf("Failed to create dir %s: %v", u.CustomAvatarRe lativePath(), err)
 End of changes. 3 change blocks. 
4 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)