mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-07-06 13:00:03 +02:00
Fix user avatar name (#8547)
Migrate avatar names to include user ID and the md5 hash.
This commit is contained in:
parent
145c1ea0b6
commit
e3a5b83212
3 changed files with 119 additions and 1 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue