summaryrefslogtreecommitdiffstats
path: root/services/asymkey/ssh_key.go
diff options
context:
space:
mode:
authorJakobDev <jakobdev@gmx.de>2023-09-25 15:17:37 +0200
committerGitHub <noreply@github.com>2023-09-25 15:17:37 +0200
commit7047df36d4c39fefa6464b713c66302aa0038123 (patch)
treea5c471a3e8abf5cabac8de42c0fd8a814df7abf1 /services/asymkey/ssh_key.go
parentFix more "locale" usages (#27259) (diff)
downloadforgejo-7047df36d4c39fefa6464b713c66302aa0038123.tar.xz
forgejo-7047df36d4c39fefa6464b713c66302aa0038123.zip
Another round of `db.DefaultContext` refactor (#27103)
Part of #27065 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Diffstat (limited to 'services/asymkey/ssh_key.go')
-rw-r--r--services/asymkey/ssh_key.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/services/asymkey/ssh_key.go b/services/asymkey/ssh_key.go
index 0809458107..204d9c58f3 100644
--- a/services/asymkey/ssh_key.go
+++ b/services/asymkey/ssh_key.go
@@ -4,13 +4,15 @@
package asymkey
import (
+ "context"
+
asymkey_model "code.gitea.io/gitea/models/asymkey"
"code.gitea.io/gitea/models/db"
user_model "code.gitea.io/gitea/models/user"
)
// DeletePublicKey deletes SSH key information both in database and authorized_keys file.
-func DeletePublicKey(doer *user_model.User, id int64) (err error) {
+func DeletePublicKey(ctx context.Context, doer *user_model.User, id int64) (err error) {
key, err := asymkey_model.GetPublicKeyByID(id)
if err != nil {
return err
@@ -25,13 +27,13 @@ func DeletePublicKey(doer *user_model.User, id int64) (err error) {
}
}
- ctx, committer, err := db.TxContext(db.DefaultContext)
+ dbCtx, committer, err := db.TxContext(ctx)
if err != nil {
return err
}
defer committer.Close()
- if err = asymkey_model.DeletePublicKeys(ctx, id); err != nil {
+ if err = asymkey_model.DeletePublicKeys(dbCtx, id); err != nil {
return err
}
@@ -41,8 +43,8 @@ func DeletePublicKey(doer *user_model.User, id int64) (err error) {
committer.Close()
if key.Type == asymkey_model.KeyTypePrincipal {
- return asymkey_model.RewriteAllPrincipalKeys(db.DefaultContext)
+ return asymkey_model.RewriteAllPrincipalKeys(ctx)
}
- return asymkey_model.RewriteAllPublicKeys()
+ return asymkey_model.RewriteAllPublicKeys(ctx)
}