diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-11-22 10:22:53 -0500 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-11-22 10:22:53 -0500 |
commit | dc53270da91c369cb00f992a600a1e014d555278 (patch) | |
tree | 459c48745c0b4a47ece248086f5edb77ca823260 /models | |
parent | 8ea7ba3afa686303f6597f6244bd9280f0b69a23 (diff) | |
download | gitea-dc53270da91c369cb00f992a600a1e014d555278.tar.gz gitea-dc53270da91c369cb00f992a600a1e014d555278.zip |
Fix 653
Diffstat (limited to 'models')
-rw-r--r-- | models/user.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/models/user.go b/models/user.go index b0cc2ae156..9eead462e2 100644 --- a/models/user.go +++ b/models/user.go @@ -140,10 +140,14 @@ func (u *User) ValidtePassword(passwd string) bool { return u.Passwd == newUser.Passwd } +// CustomAvatarPath returns user custom avatar file path. +func (u *User) CustomAvatarPath() string { + return filepath.Join(setting.AvatarUploadPath, com.ToStr(u.Id)) +} + // UploadAvatar saves custom avatar for user. // FIXME: splite uploads to different subdirs in case we have massive users. func (u *User) UploadAvatar(data []byte) error { - savePath := filepath.Join(setting.AvatarUploadPath, com.ToStr(u.Id)) u.UseCustomAvatar = true img, _, err := image.Decode(bytes.NewReader(data)) @@ -164,7 +168,7 @@ func (u *User) UploadAvatar(data []byte) error { } os.MkdirAll(setting.AvatarUploadPath, os.ModePerm) - fw, err := os.Create(savePath) + fw, err := os.Create(u.CustomAvatarPath()) if err != nil { sess.Rollback() return err |