Skip to content

Commit

Permalink
fix 500 when delete orgnization and resolved #486
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored and bkcsoft committed Dec 27, 2016
1 parent 59f736d commit ba134bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 7 additions & 6 deletions models/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,9 @@ func Organizations(opts *SearchUserOptions) ([]*User, error) {

// DeleteOrganization completely and permanently deletes everything of organization.
func DeleteOrganization(org *User) (err error) {
if err := DeleteUser(org); err != nil {
return err
}

sess := x.NewSession()
defer sessionRelease(sess)
defer sess.Close()

if err = sess.Begin(); err != nil {
return err
}
Expand All @@ -235,7 +232,11 @@ func DeleteOrganization(org *User) (err error) {
return fmt.Errorf("deleteUser: %v", err)
}

return sess.Commit()
if err = sess.Commit(); err != nil {
return err
}

return RewriteAllPublicKeys()
}

// ________ ____ ___
Expand Down
6 changes: 4 additions & 2 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,10 @@ func deleteUser(e *xorm.Session, u *User) error {
}

avatarPath := u.CustomAvatarPath()
if err := os.Remove(avatarPath); err != nil {
return fmt.Errorf("Fail to remove %s: %v", avatarPath, err)
if com.IsExist(avatarPath) {
if err := os.Remove(avatarPath); err != nil {
return fmt.Errorf("Fail to remove %s: %v", avatarPath, err)
}
}

return nil
Expand Down

0 comments on commit ba134bd

Please sign in to comment.