Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 500 when delete orgnization and resolved #486 #507

Merged
merged 1 commit into from
Dec 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions models/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,9 @@ func Organizations(page, pageSize int) ([]*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 @@ -228,7 +225,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 @@ -885,8 +885,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