1
1
mirror of https://github.com/go-gitea/gitea synced 2025-11-16 03:08:18 +00:00

Use db.WithTx/WithTx2 instead of TxContext when possible (#35130)

This commit is contained in:
Lunny Xiao
2025-07-23 01:02:01 +08:00
committed by GitHub
parent f201dde945
commit 65cd3f5309
56 changed files with 1999 additions and 2640 deletions

View File

@@ -47,26 +47,19 @@ func updateIssueLock(ctx context.Context, opts *IssueLockOptions, lock bool) err
commentType = CommentTypeUnlock
}
ctx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
defer committer.Close()
return db.WithTx(ctx, func(ctx context.Context) error {
if err := UpdateIssueCols(ctx, opts.Issue, "is_locked"); err != nil {
return err
}
if err := UpdateIssueCols(ctx, opts.Issue, "is_locked"); err != nil {
opt := &CreateCommentOptions{
Doer: opts.Doer,
Issue: opts.Issue,
Repo: opts.Issue.Repo,
Type: commentType,
Content: opts.Reason,
}
_, err := CreateComment(ctx, opt)
return err
}
opt := &CreateCommentOptions{
Doer: opts.Doer,
Issue: opts.Issue,
Repo: opts.Issue.Repo,
Type: commentType,
Content: opts.Reason,
}
if _, err := CreateComment(ctx, opt); err != nil {
return err
}
return committer.Commit()
})
}