Resolve TODO: Enable pagination on GiteaDownloader.GetComments() & update another TODO (#16963)

* Update TODO in migrations

* Resolve TODO: enable pagination on GiteaDownloader.GetComments()
This commit is contained in:
6543 2021-09-06 18:00:50 +02:00 committed by GitHub
parent a807031a30
commit cf6d398485
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 44 deletions

View file

@ -459,7 +459,7 @@ func (g *GiteaDownloader) GetIssues(page, perPage int) ([]*base.Issue, bool, err
func (g *GiteaDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Comment, bool, error) { func (g *GiteaDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Comment, bool, error) {
var allComments = make([]*base.Comment, 0, g.maxPerPage) var allComments = make([]*base.Comment, 0, g.maxPerPage)
// for i := 1; ; i++ { for i := 1; ; i++ {
// make sure gitea can shutdown gracefully // make sure gitea can shutdown gracefully
select { select {
case <-g.ctx.Done(): case <-g.ctx.Done():
@ -468,8 +468,8 @@ func (g *GiteaDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Comm
} }
comments, _, err := g.client.ListIssueComments(g.repoOwner, g.repoName, opts.Context.ForeignID(), gitea_sdk.ListIssueCommentOptions{ListOptions: gitea_sdk.ListOptions{ comments, _, err := g.client.ListIssueComments(g.repoOwner, g.repoName, opts.Context.ForeignID(), gitea_sdk.ListIssueCommentOptions{ListOptions: gitea_sdk.ListOptions{
// PageSize: g.maxPerPage, PageSize: g.maxPerPage,
// Page: i, Page: i,
}}) }})
if err != nil { if err != nil {
return nil, false, fmt.Errorf("error while listing comments for issue #%d. Error: %v", opts.Context.ForeignID(), err) return nil, false, fmt.Errorf("error while listing comments for issue #%d. Error: %v", opts.Context.ForeignID(), err)
@ -497,11 +497,10 @@ func (g *GiteaDownloader) GetComments(opts base.GetCommentOptions) ([]*base.Comm
}) })
} }
// TODO enable pagination vor (gitea >= 1.14) when it got implemented if !g.pagination || len(comments) < g.maxPerPage {
// if !g.pagination || len(comments) < g.maxPerPage { break
// break }
// } }
//}
return allComments, true, nil return allComments, true, nil
} }

View file

@ -475,10 +475,7 @@ func Init() error {
return nil return nil
} }
// isIPPrivate reports whether ip is a private address, according to // TODO: replace with `ip.IsPrivate()` if min go version is bumped to 1.17
// RFC 1918 (IPv4 addresses) and RFC 4193 (IPv6 addresses).
// from https://github.com/golang/go/pull/42793
// TODO remove if https://github.com/golang/go/issues/29146 got resolved
func isIPPrivate(ip net.IP) bool { func isIPPrivate(ip net.IP) bool {
if ip4 := ip.To4(); ip4 != nil { if ip4 := ip.To4(); ip4 != nil {
return ip4[0] == 10 || return ip4[0] == 10 ||