mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Fix user avatar name (#8547)
Migrate avatar names to include user ID and the md5 hash.
This commit is contained in:
@@ -521,7 +521,11 @@ func (u *User) UploadAvatar(data []byte) error {
|
||||
}
|
||||
|
||||
u.UseCustomAvatar = true
|
||||
u.Avatar = fmt.Sprintf("%x", md5.Sum(data))
|
||||
// Different users can upload same image as avatar
|
||||
// If we prefix it with u.ID, it will be separated
|
||||
// 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 {
|
||||
return fmt.Errorf("updateUser: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user