Skip to content

Commit

Permalink
refactor(crawler): save only new versions
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Dec 26, 2024
1 parent bbbe9d8 commit fc11d46
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ func (c *Crawler) crawlSHA1(ctx context.Context, baseURL string, meta *Metadata,
})
}

versions = lo.Filter(versions, func(v types.Version, _ int) bool {
_, ok := savedVersion[v.Version]
return !ok
})

foundVersions = append(foundVersions, versions...)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/crawler/crawler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestCrawl(t *testing.T) {
"/maven2/abbot/abbot/1.4.0/abbot-1.4.0.jar.sha1": "testdata/happy/abbot-1.4.0.jar.sha1",
"/maven2/abbot/abbot/1.4.0/abbot-1.4.0-lite.jar.sha1": "testdata/happy/abbot-1.4.0-lite.jar.sha1",
},
goldenPath: "testdata/happy/abbot.json.golden",
goldenPath: "testdata/happy/abbot-with-db.json.golden",
filePath: "indexes/abbot/abbot.json",
},
{
Expand Down
15 changes: 15 additions & 0 deletions pkg/crawler/testdata/happy/abbot-with-db.json.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"GroupID": "abbot",
"ArtifactID": "abbot",
"Versions": [
{
"Version": "1.4.0-lite",
"SHA1": "BUerA3Bor6ICaSW9lL+5/Pzsl2E="
},
{
"Version": "1.4.0",
"SHA1": "ojY2RqndBZVWM7RQAQtZohr4pCM="
}
],
"ArchiveType": "jar"
}

0 comments on commit fc11d46

Please sign in to comment.