Skip to content

Commit

Permalink
refactor: update parseMetadata function
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Mar 7, 2024
1 parent dd71b0a commit 1c42070
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,13 @@ func (c *Crawler) parseMetadata(ctx context.Context, url string) (*Metadata, err
if err = xml.NewDecoder(resp.Body).Decode(&meta); err != nil {
return nil, xerrors.Errorf("%s decode error: %w", url, err)
}
// we don't need metadata.xml files from version folder
// e.g. https://repo.maven.apache.org/maven2/HTTPClient/HTTPClient/0.3-3/maven-metadata.xml
if len(meta.Versioning.Versions) == 0 {
// Skip metadata without `GroupID` and ArtifactID` fields
// e.g. https://repo.maven.apache.org/maven2/at/molindo/maven-metadata.xml
if meta.ArtifactID == "" || meta.GroupID == "" {
log.Fatalf(url)
return nil, nil
}

// also we need to skip metadata.xml files from groupID folder
// e.g. https://repo.maven.apache.org/maven2/args4j/maven-metadata.xml
if len(strings.Split(url, "/")) < 7 {
Expand Down

0 comments on commit 1c42070

Please sign in to comment.