summaryrefslogtreecommitdiffstats
path: root/models/asymkey/gpg_key_add.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/asymkey/gpg_key_add.go')
-rw-r--r--models/asymkey/gpg_key_add.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/models/asymkey/gpg_key_add.go b/models/asymkey/gpg_key_add.go
index 8f84bba1df..d01f2deb03 100644
--- a/models/asymkey/gpg_key_add.go
+++ b/models/asymkey/gpg_key_add.go
@@ -5,6 +5,7 @@
package asymkey
import (
+ "context"
"strings"
"code.gitea.io/gitea/models/db"
@@ -29,21 +30,21 @@ import (
// This file contains functions relating to adding GPG Keys
// addGPGKey add key, import and subkeys to database
-func addGPGKey(e db.Engine, key *GPGKey, content string) (err error) {
+func addGPGKey(ctx context.Context, key *GPGKey, content string) (err error) {
// Add GPGKeyImport
- if _, err = e.Insert(GPGKeyImport{
+ if err = db.Insert(ctx, &GPGKeyImport{
KeyID: key.KeyID,
Content: content,
}); err != nil {
return err
}
// Save GPG primary key.
- if _, err = e.Insert(key); err != nil {
+ if err = db.Insert(ctx, key); err != nil {
return err
}
// Save GPG subs key.
for _, subkey := range key.SubsKey {
- if err := addGPGSubKey(e, subkey); err != nil {
+ if err := addGPGSubKey(ctx, subkey); err != nil {
return err
}
}
@@ -51,14 +52,14 @@ func addGPGKey(e db.Engine, key *GPGKey, content string) (err error) {
}
// addGPGSubKey add subkeys to database
-func addGPGSubKey(e db.Engine, key *GPGKey) (err error) {
+func addGPGSubKey(ctx context.Context, key *GPGKey) (err error) {
// Save GPG primary key.
- if _, err = e.Insert(key); err != nil {
+ if err = db.Insert(ctx, key); err != nil {
return err
}
// Save GPG subs key.
for _, subkey := range key.SubsKey {
- if err := addGPGSubKey(e, subkey); err != nil {
+ if err := addGPGSubKey(ctx, subkey); err != nil {
return err
}
}
@@ -158,7 +159,7 @@ func AddGPGKey(ownerID int64, content, token, signature string) ([]*GPGKey, erro
return nil, err
}
- if err = addGPGKey(db.GetEngine(ctx), key, content); err != nil {
+ if err = addGPGKey(ctx, key, content); err != nil {
return nil, err
}
keys = append(keys, key)