diff options
author | Masudur Rahman <masudjuly02@gmail.com> | 2019-12-28 00:27:59 +0600 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-12-27 18:27:59 +0000 |
commit | e3a5b8321240e489bb9048ecf2caccf73c0abc36 (patch) | |
tree | 60ab5abffed6f06753ea3e2436e95a88bbe30f05 /models/user.go | |
parent | 145c1ea0b6b1f79eff047041853378319117fd39 (diff) | |
download | gitea-e3a5b8321240e489bb9048ecf2caccf73c0abc36.tar.gz gitea-e3a5b8321240e489bb9048ecf2caccf73c0abc36.zip |
Fix user avatar name (#8547)
Migrate avatar names to include user ID and the md5 hash.
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/models/user.go b/models/user.go index 0454158de6..e832c2ed51 100644 --- a/models/user.go +++ b/models/user.go @@ -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) } |