aboutsummaryrefslogtreecommitdiffstats
path: root/models/issue_lock.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-19 21:39:57 +0800
committerGitHub <noreply@github.com>2021-11-19 21:39:57 +0800
commitfc3d0826096943b979717ed46c9a4cfd86e06106 (patch)
tree3143882ccf4dea3a8bf2a0de9c8da9a4efec26ce /models/issue_lock.go
parent7a0347315995b25bcb2dca4786504fb699b5f004 (diff)
downloadgitea-fc3d0826096943b979717ed46c9a4cfd86e06106.tar.gz
gitea-fc3d0826096943b979717ed46c9a4cfd86e06106.zip
Move attachment into models/repo/ (#17650)
* Move attachment into models/repo/ * Fix test * Fix bug
Diffstat (limited to 'models/issue_lock.go')
-rw-r--r--models/issue_lock.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/models/issue_lock.go b/models/issue_lock.go
index d8e3b4c0ab..d0b9c660c2 100644
--- a/models/issue_lock.go
+++ b/models/issue_lock.go
@@ -37,13 +37,13 @@ func updateIssueLock(opts *IssueLockOptions, lock bool) error {
commentType = CommentTypeUnlock
}
- 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()
- if err := updateIssueCols(sess, opts.Issue, "is_locked"); err != nil {
+ if err := updateIssueCols(db.GetEngine(ctx), opts.Issue, "is_locked"); err != nil {
return err
}
@@ -54,9 +54,9 @@ func updateIssueLock(opts *IssueLockOptions, lock bool) error {
Type: commentType,
Content: opts.Reason,
}
- if _, err := createComment(sess, opt); err != nil {
+ if _, err := createComment(ctx, opt); err != nil {
return err
}
- return sess.Commit()
+ return committer.Commit()
}