diff options
-rw-r--r-- | models/org.go | 13 | ||||
-rw-r--r-- | models/user.go | 6 |
2 files changed, 11 insertions, 8 deletions
diff --git a/models/org.go b/models/org.go index b302288ca5..43a3e094f1 100644 --- a/models/org.go +++ b/models/org.go @@ -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 } @@ -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() } // ________ ____ ___ diff --git a/models/user.go b/models/user.go index 803cb3b03e..d48397ef7e 100644 --- a/models/user.go +++ b/models/user.go @@ -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 |