mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-31 06:21:11 +00:00 
			
		
		
		
	Fixes https://codeberg.org/forgejo/forgejo/issues/1514 Backports #27273 --------- Co-authored-by: JakobDev <jakobdev@gmx.de>
This commit is contained in:
		
					parent
					
						
							
								6ac2ade97d
							
						
					
				
			
			
				commit
				
					
						6637bbf510
					
				
			
		
					 14 changed files with 79 additions and 51 deletions
				
			
		|  | @ -425,3 +425,30 @@ func RemoveRepositoryFromTeam(ctx context.Context, t *organization.Team, repoID | |||
| 
 | ||||
| 	return committer.Commit() | ||||
| } | ||||
| 
 | ||||
| // DeleteOwnerRepositoriesDirectly calls DeleteRepositoryDirectly for all repos of the given owner | ||||
| func DeleteOwnerRepositoriesDirectly(ctx context.Context, owner *user_model.User) error { | ||||
| 	for { | ||||
| 		repos, _, err := repo_model.GetUserRepositories(ctx, &repo_model.SearchRepoOptions{ | ||||
| 			ListOptions: db.ListOptions{ | ||||
| 				PageSize: repo_model.RepositoryListDefaultPageSize, | ||||
| 				Page:     1, | ||||
| 			}, | ||||
| 			Private: true, | ||||
| 			OwnerID: owner.ID, | ||||
| 			Actor:   owner, | ||||
| 		}) | ||||
| 		if err != nil { | ||||
| 			return fmt.Errorf("GetUserRepositories: %w", err) | ||||
| 		} | ||||
| 		if len(repos) == 0 { | ||||
| 			break | ||||
| 		} | ||||
| 		for _, repo := range repos { | ||||
| 			if err := DeleteRepositoryDirectly(ctx, owner, owner.ID, repo.ID); err != nil { | ||||
| 				return fmt.Errorf("unable to delete repository %s for %s[%d]. Error: %w", repo.Name, owner.Name, owner.ID, err) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue