internal/build: don't crash in DownloadFile when offline

This commit is contained in:
Felix Lange 2020-01-27 12:37:38 +01:00
parent 7b68975a00
commit c6c58895fe

View file

@ -83,8 +83,10 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
fmt.Printf("downloading from %s\n", url) fmt.Printf("downloading from %s\n", url)
resp, err := http.Get(url) resp, err := http.Get(url)
if err != nil || resp.StatusCode != http.StatusOK { if err != nil {
return fmt.Errorf("download error: code %d, err %v", resp.StatusCode, err) 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() defer resp.Body.Close()
if err := os.MkdirAll(filepath.Dir(dstPath), 0755); err != nil { if err := os.MkdirAll(filepath.Dir(dstPath), 0755); err != nil {