mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-22 15:18:30 -04:00
parent
7480aacdad
commit
cddf245c12
33 changed files with 99 additions and 85 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue