Skip to content

Commit 9ec3c19

Browse files
author
Massimiliano Giovagnoli
committed
feat(pkg/find): enable colly to run async
Signed-off-by: Massimiliano Giovagnoli <me@maxgio.it>
1 parent f00caf5 commit 9ec3c19

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pkg/find/file.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (o *Options) crawlFiles() (*Result, error) {
4242
// Create the collector settings
4343
coOptions := []func(*colly.Collector){
4444
colly.AllowedDomains(allowedDomains...),
45-
colly.Async(false),
45+
colly.Async(true),
4646
}
4747

4848
if o.Verbose {
@@ -92,5 +92,8 @@ func (o *Options) crawlFiles() (*Result, error) {
9292
}
9393
}
9494

95+
// Wait until colly goroutines are finished.
96+
co.Wait()
97+
9598
return &Result{BaseNames: files, URLs: urls}, nil
9699
}

pkg/find/folder.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (o *Options) crawlFolders() (*Result, error) {
4343
// Create the collector settings
4444
coOptions := []func(*colly.Collector){
4545
colly.AllowedDomains(allowedDomains...),
46-
colly.Async(false),
46+
colly.Async(true),
4747
}
4848

4949
if o.Verbose {
@@ -100,5 +100,8 @@ func (o *Options) crawlFolders() (*Result, error) {
100100
}
101101
}
102102

103+
// Wait until colly goroutines are finished.
104+
co.Wait()
105+
103106
return &Result{BaseNames: folders, URLs: urls}, nil
104107
}

0 commit comments

Comments
 (0)