From e26e6282e24f4e63fb75745aeec99edee4a02ba6 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Fri, 12 Sep 2025 13:17:58 -0400 Subject: [PATCH] use withtx2 correctly --- models/repo/mirror_ssh_keypair.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/models/repo/mirror_ssh_keypair.go b/models/repo/mirror_ssh_keypair.go index 1503173197..4cb5d90d2b 100644 --- a/models/repo/mirror_ssh_keypair.go +++ b/models/repo/mirror_ssh_keypair.go @@ -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 }