internal/build: don't crash in DownloadFile when offline (#20595)

pull/20626/head
Felix Lange 5 years ago committed by GitHub
parent 15d09038a6
commit 4cc89a5a32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      internal/build/download.go

@ -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 {

Loading…
Cancel
Save