Skip to content

Commit 0376029

Browse files
authored
fix del org avatar potential delete all avtars (#1120)
1 parent 7b64b2d commit 0376029

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

models/org.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,12 @@ func deleteOrg(e *xorm.Session, u *User) error {
275275
return fmt.Errorf("Failed to RemoveAll %s: %v", path, err)
276276
}
277277

278-
avatarPath := u.CustomAvatarPath()
279-
if com.IsExist(avatarPath) {
280-
if err := os.Remove(avatarPath); err != nil {
281-
return fmt.Errorf("Failed to remove %s: %v", avatarPath, err)
278+
if len(u.Avatar) > 0 {
279+
avatarPath := u.CustomAvatarPath()
280+
if com.IsExist(avatarPath) {
281+
if err := os.Remove(avatarPath); err != nil {
282+
return fmt.Errorf("Failed to remove %s: %v", avatarPath, err)
283+
}
282284
}
283285
}
284286

0 commit comments

Comments
 (0)