Skip to content

Move all mail related codes from models to services/mailer #7200

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

Merged
merged 18 commits into from
Sep 24, 2019
Merged
Prev Previous commit
Next Next commit
don't use defer when sess.Close()
  • Loading branch information
lunny committed Sep 24, 2019
commit 7ddef4c26a69dc68a20f843127e7931dd93da595
7 changes: 5 additions & 2 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,19 @@ func WithContext(f func(ctx DBContext) error) error {
// WithTransaction represents executing database operations on a trasaction
func WithTransaction(f func(ctx DBContext) error) error {
sess := x.NewSession()
defer sess.Close()
if err := sess.Begin(); err != nil {
sess.Close()
return err
}

if err := f(DBContext{sess}); err != nil {
sess.Close()
return err
}

return sess.Commit()
err := sess.Commit()
sess.Close()
return err
}

func getEngine() (*xorm.Engine, error) {
Expand Down