1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Replace more db.DefaultContext (#27628)

Target #27065
This commit is contained in:
Lunny Xiao
2023-10-15 23:46:06 +08:00
committed by GitHub
parent 7480aacdad
commit cddf245c12
33 changed files with 99 additions and 85 deletions

View File

@@ -23,8 +23,8 @@ func init() {
}
// SaveAppStateContent saves the app state item to database
func SaveAppStateContent(key, content string) error {
return db.WithTx(db.DefaultContext, func(ctx context.Context) error {
func SaveAppStateContent(ctx context.Context, key, content string) error {
return db.WithTx(ctx, func(ctx context.Context) error {
eng := db.GetEngine(ctx)
// try to update existing row
res, err := eng.Exec("UPDATE app_state SET revision=revision+1, content=? WHERE id=?", content, key)
@@ -43,8 +43,8 @@ func SaveAppStateContent(key, content string) error {
}
// GetAppStateContent gets an app state from database
func GetAppStateContent(key string) (content string, err error) {
e := db.GetEngine(db.DefaultContext)
func GetAppStateContent(ctx context.Context, key string) (content string, err error) {
e := db.GetEngine(ctx)
appState := &AppState{ID: key}
has, err := e.Get(appState)
if err != nil {