Skip to content

Commit

Permalink
feat(pkg/find): enable colly to run async
Browse files Browse the repository at this point in the history
Signed-off-by: Massimiliano Giovagnoli <me@maxgio.it>
  • Loading branch information
maxgio92 committed Jul 4, 2023
1 parent f00caf5 commit 9ec3c19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/find/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (o *Options) crawlFiles() (*Result, error) {
// Create the collector settings
coOptions := []func(*colly.Collector){
colly.AllowedDomains(allowedDomains...),
colly.Async(false),
colly.Async(true),
}

if o.Verbose {
Expand Down Expand Up @@ -92,5 +92,8 @@ func (o *Options) crawlFiles() (*Result, error) {
}
}

// Wait until colly goroutines are finished.
co.Wait()

return &Result{BaseNames: files, URLs: urls}, nil
}
5 changes: 4 additions & 1 deletion pkg/find/folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (o *Options) crawlFolders() (*Result, error) {
// Create the collector settings
coOptions := []func(*colly.Collector){
colly.AllowedDomains(allowedDomains...),
colly.Async(false),
colly.Async(true),
}

if o.Verbose {
Expand Down Expand Up @@ -100,5 +100,8 @@ func (o *Options) crawlFolders() (*Result, error) {
}
}

// Wait until colly goroutines are finished.
co.Wait()

return &Result{BaseNames: folders, URLs: urls}, nil
}

0 comments on commit 9ec3c19

Please sign in to comment.