summaryrefslogtreecommitdiffstats
path: root/models/upload.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-21 23:41:00 +0800
committerGitHub <noreply@github.com>2021-11-21 23:41:00 +0800
commitd710af6669654f27f02b69d7ef1ba563e7d58a90 (patch)
tree9727f468a570106293dc90beb70035180bbb7e8e /models/upload.go
parent0add627182388ac63fd04b94cdf912fb87fd0326 (diff)
downloadgitea-d710af6669654f27f02b69d7ef1ba563e7d58a90.tar.gz
gitea-d710af6669654f27f02b69d7ef1ba563e7d58a90.zip
Remove NewSession method from db.Engine interface (#17577)
* Remove NewSession method from db.Engine interface * Fix bug * Some improvements * Fix bug * Fix test * Use XXXBean instead of XXXExample
Diffstat (limited to 'models/upload.go')
-rw-r--r--models/upload.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/models/upload.go b/models/upload.go
index 503220db57..4a64ff34e3 100644
--- a/models/upload.go
+++ b/models/upload.go
@@ -109,23 +109,23 @@ func DeleteUploads(uploads ...*Upload) (err error) {
return nil
}
- sess := db.NewSession(db.DefaultContext)
- defer sess.Close()
- if err = sess.Begin(); err != nil {
+ ctx, committer, err := db.TxContext()
+ if err != nil {
return err
}
+ defer committer.Close()
ids := make([]int64, len(uploads))
for i := 0; i < len(uploads); i++ {
ids[i] = uploads[i].ID
}
- if _, err = sess.
+ if _, err = db.GetEngine(ctx).
In("id", ids).
Delete(new(Upload)); err != nil {
return fmt.Errorf("delete uploads: %v", err)
}
- if err = sess.Commit(); err != nil {
+ if err = committer.Commit(); err != nil {
return err
}