From 03760292412ffb3f65f2bfc359cb3bda100c5c98 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 6 Mar 2017 16:07:18 +0800 Subject: [PATCH] fix del org avatar potential delete all avtars (#1120) --- models/org.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/models/org.go b/models/org.go index 49dcfcaa6..d6cbcc965 100644 --- a/models/org.go +++ b/models/org.go @@ -275,10 +275,12 @@ func deleteOrg(e *xorm.Session, u *User) error { return fmt.Errorf("Failed to RemoveAll %s: %v", path, err) } - avatarPath := u.CustomAvatarPath() - if com.IsExist(avatarPath) { - if err := os.Remove(avatarPath); err != nil { - return fmt.Errorf("Failed to remove %s: %v", avatarPath, err) + if len(u.Avatar) > 0 { + avatarPath := u.CustomAvatarPath() + if com.IsExist(avatarPath) { + if err := os.Remove(avatarPath); err != nil { + return fmt.Errorf("Failed to remove %s: %v", avatarPath, err) + } } }