Skip to content

Commit 66cead0

Browse files
Fix user avatar name
Signed-off-by: Masudur Rahman <[email protected]>
1 parent 1db2381 commit 66cead0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

models/user.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,11 @@ func (u *User) UploadAvatar(data []byte) error {
521521
}
522522

523523
u.UseCustomAvatar = true
524-
u.Avatar = fmt.Sprintf("%x", md5.Sum(data))
524+
// Different users can upload same image as avatar
525+
// If we prefix it with u.ID, it will be separated
526+
// Otherwise, if any of the users delete his avatar
527+
// Other users will lose their avatars too.
528+
u.Avatar = fmt.Sprintf("%d-%x", u.ID, md5.Sum(data))
525529
if err = updateUser(sess, u); err != nil {
526530
return fmt.Errorf("updateUser: %v", err)
527531
}

0 commit comments

Comments
 (0)