Skip to content

Commit

Permalink
internal/build: don't crash in DownloadFile when offline (ethereum#20595
Browse files Browse the repository at this point in the history
)
  • Loading branch information
fjl authored and enriquefynn committed Feb 15, 2021
1 parent 2a14d53 commit 190f899
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/build/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
fmt.Printf("downloading from %s\n", url)

resp, err := http.Get(url)
if err != nil || resp.StatusCode != http.StatusOK {
return fmt.Errorf("download error: code %d, err %v", resp.StatusCode, err)
if err != nil {
return fmt.Errorf("download error: %v", err)
} else if resp.StatusCode != http.StatusOK {
return fmt.Errorf("download error: status %d", resp.StatusCode)
}
defer resp.Body.Close()
if err := os.MkdirAll(filepath.Dir(dstPath), 0755); err != nil {
Expand Down

0 comments on commit 190f899

Please sign in to comment.