diff options
author | Unknwon <u@gogs.io> | 2015-09-06 08:54:08 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-09-06 08:54:08 -0400 |
commit | aa67de910af6246a6dc9ad96c56f789e282e8403 (patch) | |
tree | c845cd7afe587d341a091507d2f08310a816e509 /models/org.go | |
parent | 24658fcbdd507bd66cd76b6ca96e1ef5e1c15af5 (diff) | |
download | gitea-aa67de910af6246a6dc9ad96c56f789e282e8403.tar.gz gitea-aa67de910af6246a6dc9ad96c56f789e282e8403.zip |
fix #1558
Diffstat (limited to 'models/org.go')
-rw-r--r-- | models/org.go | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/models/org.go b/models/org.go index dfd720fade..ac458c78d5 100644 --- a/models/org.go +++ b/models/org.go @@ -212,7 +212,6 @@ func GetOrganizations(num, offset int) ([]*User, error) { return orgs, err } -// TODO: need some kind of mechanism to record failure. // DeleteOrganization completely and permanently deletes everything of organization. func DeleteOrganization(org *User) (err error) { if err := DeleteUser(org); err != nil { @@ -220,23 +219,23 @@ func DeleteOrganization(org *User) (err error) { } sess := x.NewSession() - defer sess.Close() + defer sessionRelease(sess) if err = sess.Begin(); err != nil { return err } - if _, err = sess.Delete(&Team{OrgID: org.Id}); err != nil { - sess.Rollback() - return err + if err = deleteBeans(sess, + &Team{OrgID: org.Id}, + &OrgUser{OrgID: org.Id}, + &TeamUser{OrgID: org.Id}, + ); err != nil { + return fmt.Errorf("deleteBeans: %v", err) } - if _, err = sess.Delete(&OrgUser{OrgID: org.Id}); err != nil { - sess.Rollback() - return err - } - if _, err = sess.Delete(&TeamUser{OrgID: org.Id}); err != nil { - sess.Rollback() - return err + + if err = deleteUser(sess, org); err != nil { + return fmt.Errorf("deleteUser: %v", err) } + return sess.Commit() } |