mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-22 01:34:18 +00:00
Add context parameter to some database functions (#26055)
To avoid deadlock problem, almost database related functions should be have ctx as the first parameter. This PR do a refactor for some of these functions.
This commit is contained in:
parent
c42b71877e
commit
b167f35113
50 changed files with 209 additions and 237 deletions
|
@ -6,7 +6,6 @@ package issue
|
|||
import (
|
||||
"context"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
|
@ -14,13 +13,7 @@ import (
|
|||
)
|
||||
|
||||
// ChangeStatus changes issue status to open or closed.
|
||||
func ChangeStatus(issue *issues_model.Issue, doer *user_model.User, commitID string, closed bool) error {
|
||||
return changeStatusCtx(db.DefaultContext, issue, doer, commitID, closed)
|
||||
}
|
||||
|
||||
// changeStatusCtx changes issue status to open or closed.
|
||||
// TODO: if context is not db.DefaultContext we get a deadlock!!!
|
||||
func changeStatusCtx(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, commitID string, closed bool) error {
|
||||
func ChangeStatus(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, commitID string, closed bool) error {
|
||||
comment, err := issues_model.ChangeIssueStatus(ctx, issue, doer, closed)
|
||||
if err != nil {
|
||||
if issues_model.IsErrDependenciesLeft(err) && closed {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue