mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-23 18:54:39 +02:00
use withtx2 correctly
This commit is contained in:
1 parent
1d9e98c5af
commit
e26e6282e2
1 file changed
+3
-6
@@ -157,16 +157,13 @@ func DeleteUserSSHKeypair(ctx context.Context, ownerID int64) error {
|
||||
|
||||
// RegenerateUserSSHKeypair regenerates an SSH keypair for the given owner
|
||||
func RegenerateUserSSHKeypair(ctx context.Context, ownerID int64) (*UserSSHKeypair, error) {
|
||||
var keypair *UserSSHKeypair
|
||||
err := db.WithTx2(ctx, func(ctx context.Context) error {
|
||||
return db.WithTx2(ctx, func(ctx context.Context) (*UserSSHKeypair, error) {
|
||||
_ = DeleteUserSSHKeypair(ctx, ownerID)
|
||||
|
||||
newKeypair, err := CreateUserSSHKeypair(ctx, ownerID)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
keypair = newKeypair
|
||||
return nil
|
||||
return newKeypair, nil
|
||||
})
|
||||
return keypair, err
|
||||
}
|
||||
Reference in new issue
Block a user