mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-06 18:35:23 +02:00
Use for a repo action one database transaction (#19576)
... more context (part of #9307)
This commit is contained in:
parent
730420b6b3
commit
92f139d091
29 changed files with 270 additions and 260 deletions
|
@ -5,6 +5,8 @@
|
|||
package issue
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
|
@ -14,10 +16,16 @@ import (
|
|||
|
||||
// ChangeStatus changes issue status to open or closed.
|
||||
func ChangeStatus(issue *models.Issue, doer *user_model.User, closed bool) error {
|
||||
comment, err := models.ChangeIssueStatus(issue, doer, closed)
|
||||
return changeStatusCtx(db.DefaultContext, issue, doer, 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 *models.Issue, doer *user_model.User, closed bool) error {
|
||||
comment, err := models.ChangeIssueStatus(ctx, issue, doer, closed)
|
||||
if err != nil {
|
||||
if models.IsErrDependenciesLeft(err) && closed {
|
||||
if err := models.FinishIssueStopwatchIfPossible(db.DefaultContext, doer, issue); err != nil {
|
||||
if err := models.FinishIssueStopwatchIfPossible(ctx, doer, issue); err != nil {
|
||||
log.Error("Unable to stop stopwatch for issue[%d]#%d: %v", issue.ID, issue.Index, err)
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +33,7 @@ func ChangeStatus(issue *models.Issue, doer *user_model.User, closed bool) error
|
|||
}
|
||||
|
||||
if closed {
|
||||
if err := models.FinishIssueStopwatchIfPossible(db.DefaultContext, doer, issue); err != nil {
|
||||
if err := models.FinishIssueStopwatchIfPossible(ctx, doer, issue); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue