mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-20 17:57:14 -04: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
|
@ -284,14 +284,15 @@ type PushActionContent struct {
|
|||
|
||||
// LoadIssue loads issue from database
|
||||
func (c *Comment) LoadIssue() (err error) {
|
||||
return c.loadIssue(db.GetEngine(db.DefaultContext))
|
||||
return c.LoadIssueCtx(db.DefaultContext)
|
||||
}
|
||||
|
||||
func (c *Comment) loadIssue(e db.Engine) (err error) {
|
||||
// LoadIssueCtx loads issue from database
|
||||
func (c *Comment) LoadIssueCtx(ctx context.Context) (err error) {
|
||||
if c.Issue != nil {
|
||||
return nil
|
||||
}
|
||||
c.Issue, err = getIssueByID(e, c.IssueID)
|
||||
c.Issue, err = getIssueByID(db.GetEngine(ctx), c.IssueID)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1126,7 +1127,7 @@ func UpdateComment(c *Comment, doer *user_model.User) error {
|
|||
if _, err := sess.ID(c.ID).AllCols().Update(c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.loadIssue(sess); err != nil {
|
||||
if err := c.LoadIssueCtx(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := c.addCrossReferences(ctx, doer, true); err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue