From 962cd374e2d1d932baf6a5fd260e4f841416b7b8 Mon Sep 17 00:00:00 2001 From: Clemens Date: Tue, 2 Apr 2024 12:36:04 +0200 Subject: [PATCH] delete federated repos when deleting repository --- services/federation/federation_service.go | 7 +++++++ services/repository/repository.go | 3 +++ 2 files changed, 10 insertions(+) diff --git a/services/federation/federation_service.go b/services/federation/federation_service.go index 2fc9c844ae..64550de95a 100644 --- a/services/federation/federation_service.go +++ b/services/federation/federation_service.go @@ -237,6 +237,13 @@ func StoreFederatedRepoList(ctx context.Context, localRepoId int64, federatedRep return 0, "", nil } +func DeleteFederatedRepos(ctx context.Context, localRepoId int64) error { + if err := repo.StoreFederatedRepos(ctx, localRepoId, []*repo.FederatedRepo{}); err != nil { + return err + } + return nil +} + func SendLikeActivities(ctx context.Context, doer user.User, repoID int64) error { federatedRepos, err := repo.FindFederatedReposByRepoID(ctx, repoID) log.Info("Federated Repos is: %v", federatedRepos) diff --git a/services/repository/repository.go b/services/repository/repository.go index d28200c0ad..af0e5fee4d 100644 --- a/services/repository/repository.go +++ b/services/repository/repository.go @@ -21,6 +21,7 @@ import ( repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/structs" + federation_service "code.gitea.io/gitea/services/federation" notify_service "code.gitea.io/gitea/services/notify" pull_service "code.gitea.io/gitea/services/pull" ) @@ -66,6 +67,8 @@ func DeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_mod return err } + federation_service.DeleteFederatedRepos(ctx, repo.ID) + return packages_model.UnlinkRepositoryFromAllPackages(ctx, repo.ID) }