Skip to content

Commit

Permalink
refactor: remove error for wrong sha1. Add list of wrong sha1 to log
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Mar 5, 2024
1 parent edab71e commit c10d096
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pkg/crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ type Crawler struct {
dir string
http *retryablehttp.Client

rootUrl string
wg sync.WaitGroup
urlCh chan string
limit *semaphore.Weighted
rootUrl string
wg sync.WaitGroup
urlCh chan string
limit *semaphore.Weighted
wrongSHA1Values []string
}

type Option struct {
Expand Down Expand Up @@ -117,6 +118,12 @@ loop:
}
}
log.Println("Crawl completed")
if len(c.wrongSHA1Values) > 0 {
log.Println("Wrong sha1 files:")
for _, wrongSHA1 := range c.wrongSHA1Values {
log.Println(wrongSHA1)
}
}
return nil
}

Expand Down Expand Up @@ -325,7 +332,8 @@ func (c *Crawler) fetchSHA1(ctx context.Context, url string) ([]byte, error) {
}
}
if len(sha1b) == 0 {
return nil, xerrors.Errorf("failed to decode sha1 %s: %w", url, err)
c.wrongSHA1Values = append(c.wrongSHA1Values, fmt.Sprintf("%s (%s)", url, err))
return nil, nil
}
return sha1b, nil
}
Expand Down

0 comments on commit c10d096

Please sign in to comment.