因errgroup不支持重用,故调整为每次执行时新起

This commit is contained in:
fantasticbin 2025-03-02 21:19:10 +08:00
parent a007d4a430
commit 2d610975e8

View File

@ -21,7 +21,6 @@ type Crawler struct {
avPath string
outputPath string
config *viper.Viper
g errgroup.Group
}
func NewCrawler(avPath, outputPath string) *Crawler {
@ -220,8 +219,9 @@ func (c *Crawler) Handle() error {
return err
}
var g errgroup.Group
for _, cover := range coverList {
c.g.Go(func() error {
g.Go(func() error {
if err := c.fetchCoverImg(cover); err != nil {
return err
}
@ -230,5 +230,5 @@ func (c *Crawler) Handle() error {
})
}
return c.g.Wait()
return g.Wait()
}