-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Another round of db.DefaultContext
refactor
#27103
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once the mentioned comment has been fixed.
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was even far more than I expected 😄
ping for reviewers |
func DeleteDeployKey(doer *user_model.User, id int64) error { | ||
ctx, committer, err := db.TxContext(db.DefaultContext) | ||
func DeleteDeployKey(ctx context.Context, doer *user_model.User, id int64) error { | ||
dbCtx, committer, err := db.TxContext(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking, but we may need a better mechanism for this. If ctx
is already a transaction, TxContext
will create a halfCommitter
and the Commit
on that does nothing. Only the commit of the outer transaction commits the inner queries. But the original code depends on a finished transaction because the following actions are not reversible.
if err != nil { | ||
return err | ||
} | ||
defer committer.Close() | ||
|
||
if err := models.DeleteDeployKey(ctx, doer, id); err != nil { | ||
if err := models.DeleteDeployKey(dbCtx, doer, id); err != nil { | ||
return err | ||
} | ||
if err := committer.Commit(); err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to add committer.Close()
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Part of go-gitea#27065 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* giteaofficial/main: [skip ci] Updated translations via Crowdin Another round of `db.DefaultContext` refactor (go-gitea#27103) Fix more "locale" usages (go-gitea#27259) Always use `ctx.Locale.Tr` inside templates (go-gitea#27231) Disable `Test Delivery` and `Replay` webhook buttons when webhook is inactive (go-gitea#27211) # Conflicts: # templates/base/footer_content.tmpl # templates/repo/issue/view_content/context_menu.tmpl
Part of #27065