@@ -15,7 +15,6 @@ import (
1515 access_model "code.gitea.io/gitea/models/perm/access"
1616 project_model "code.gitea.io/gitea/models/project"
1717 repo_model "code.gitea.io/gitea/models/repo"
18- system_model "code.gitea.io/gitea/models/system"
1918 "code.gitea.io/gitea/models/unit"
2019 user_model "code.gitea.io/gitea/models/user"
2120 "code.gitea.io/gitea/modules/git"
@@ -817,36 +816,13 @@ func DeleteIssuesByRepoID(ctx context.Context, repoID int64) (attachmentPaths []
817816 return attachmentPaths , err
818817}
819818
820- // DeleteOrphanedIssues delete issues without a repo
821- func DeleteOrphanedIssues (ctx context.Context ) error {
822- var attachmentPaths []string
823- err := db .WithTx (ctx , func (ctx context.Context ) error {
824- var ids []int64
825-
826- if err := db .GetEngine (ctx ).Table ("issue" ).Distinct ("issue.repo_id" ).
827- Join ("LEFT" , "repository" , "issue.repo_id=repository.id" ).
828- Where (builder.IsNull {"repository.id" }).GroupBy ("issue.repo_id" ).
829- Find (& ids ); err != nil {
830- return err
831- }
832-
833- for i := range ids {
834- paths , err := DeleteIssuesByRepoID (ctx , ids [i ])
835- if err != nil {
836- return err
837- }
838- attachmentPaths = append (attachmentPaths , paths ... )
839- }
840-
841- return nil
842- })
843- if err != nil {
844- return err
845- }
846-
847- // Remove issue attachment files.
848- for i := range attachmentPaths {
849- system_model .RemoveAllWithNotice (ctx , "Delete issue attachment" , attachmentPaths [i ])
819+ func GetOrphanedIssueRepoIDs (ctx context.Context ) ([]int64 , error ) {
820+ var repoIDs []int64
821+ if err := db .GetEngine (ctx ).Table ("issue" ).Distinct ("issue.repo_id" ).
822+ Join ("LEFT" , "repository" , "issue.repo_id=repository.id" ).
823+ Where (builder.IsNull {"repository.id" }).GroupBy ("issue.repo_id" ).
824+ Find (& repoIDs ); err != nil {
825+ return nil , err
850826 }
851- return nil
827+ return repoIDs , nil
852828}
0 commit comments