1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-15 23:17:19 +00:00

Move delete deploy keys into service layer (#32201)

This commit is contained in:
Lunny Xiao
2024-12-17 20:10:38 -08:00
committed by GitHub
parent e4c4629465
commit f9f62b4c4c
7 changed files with 61 additions and 66 deletions

View File

@@ -7,11 +7,9 @@ import (
"context"
"fmt"
"code.gitea.io/gitea/models"
actions_model "code.gitea.io/gitea/models/actions"
activities_model "code.gitea.io/gitea/models/activities"
admin_model "code.gitea.io/gitea/models/admin"
asymkey_model "code.gitea.io/gitea/models/asymkey"
"code.gitea.io/gitea/models/db"
git_model "code.gitea.io/gitea/models/git"
issues_model "code.gitea.io/gitea/models/issues"
@@ -76,16 +74,11 @@ func DeleteRepositoryDirectly(ctx context.Context, doer *user_model.User, repoID
}
// Delete Deploy Keys
deployKeys, err := db.Find[asymkey_model.DeployKey](ctx, asymkey_model.ListDeployKeysOptions{RepoID: repoID})
deleted, err := asymkey_service.DeleteRepoDeployKeys(ctx, repoID)
if err != nil {
return fmt.Errorf("listDeployKeys: %w", err)
}
needRewriteKeysFile := len(deployKeys) > 0
for _, dKey := range deployKeys {
if err := models.DeleteDeployKey(ctx, doer, dKey.ID); err != nil {
return fmt.Errorf("deleteDeployKeys: %w", err)
}
return err
}
needRewriteKeysFile := deleted > 0
if cnt, err := sess.ID(repoID).Delete(&repo_model.Repository{}); err != nil {
return err