diff options
author | KN4CK3R <KN4CK3R@users.noreply.github.com> | 2021-04-30 21:10:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-30 21:10:39 +0200 |
commit | ee3fb92419338e12a531168b486d3c8f5c2164c0 (patch) | |
tree | e830b3747cd05f35796d0859f6e6f9b2ddbe526c /models/repo.go | |
parent | f5eb33c354fc8e61cc1be221f3b7256fd7b66615 (diff) | |
download | gitea-ee3fb92419338e12a531168b486d3c8f5c2164c0.tar.gz gitea-ee3fb92419338e12a531168b486d3c8f5c2164c0.zip |
Delete references if repository gets deleted (#15681)
* Remove DeletedBranch and LFSLocks.
* Sort beans.
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/models/repo.go b/models/repo.go index 0a0f725f09..daa94c0d50 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1455,24 +1455,26 @@ func DeleteRepository(doer *User, uid, repoID int64) error { if err := deleteBeans(sess, &Access{RepoID: repo.ID}, &Action{RepoID: repo.ID}, - &Watch{RepoID: repoID}, - &Star{RepoID: repoID}, - &Mirror{RepoID: repoID}, - &Milestone{RepoID: repoID}, - &Release{RepoID: repoID}, &Collaboration{RepoID: repoID}, - &PullRequest{BaseRepoID: repoID}, - &RepoUnit{RepoID: repoID}, - &RepoRedirect{RedirectRepoID: repoID}, - &Webhook{RepoID: repoID}, + &Comment{RefRepoID: repoID}, + &CommitStatus{RepoID: repoID}, + &DeletedBranch{RepoID: repoID}, &HookTask{RepoID: repoID}, + &LFSLock{RepoID: repoID}, + &LanguageStat{RepoID: repoID}, + &Milestone{RepoID: repoID}, + &Mirror{RepoID: repoID}, &Notification{RepoID: repoID}, - &CommitStatus{RepoID: repoID}, + &ProtectedBranch{RepoID: repoID}, + &PullRequest{BaseRepoID: repoID}, + &Release{RepoID: repoID}, &RepoIndexerStatus{RepoID: repoID}, - &LanguageStat{RepoID: repoID}, - &Comment{RefRepoID: repoID}, + &RepoRedirect{RedirectRepoID: repoID}, + &RepoUnit{RepoID: repoID}, + &Star{RepoID: repoID}, &Task{RepoID: repoID}, - &ProtectedBranch{RepoID: repoID}, + &Watch{RepoID: repoID}, + &Webhook{RepoID: repoID}, ); err != nil { return fmt.Errorf("deleteBeans: %v", err) } @@ -1488,10 +1490,6 @@ func DeleteRepository(doer *User, uid, repoID int64) error { return err } - if _, err := sess.Where("repo_id = ?", repoID).Delete(new(RepoUnit)); err != nil { - return err - } - if repo.IsFork { if _, err := sess.Exec("UPDATE `repository` SET num_forks=num_forks-1 WHERE id=?", repo.ForkID); err != nil { return fmt.Errorf("decrease fork count: %v", err) |