Skip to content

Commit 4cc89a5

Browse files
authored
internal/build: don't crash in DownloadFile when offline (#20595)
1 parent 15d0903 commit 4cc89a5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/build/download.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ func (db *ChecksumDB) DownloadFile(url, dstPath string) error {
8383
fmt.Printf("downloading from %s\n", url)
8484

8585
resp, err := http.Get(url)
86-
if err != nil || resp.StatusCode != http.StatusOK {
87-
return fmt.Errorf("download error: code %d, err %v", resp.StatusCode, err)
86+
if err != nil {
87+
return fmt.Errorf("download error: %v", err)
88+
} else if resp.StatusCode != http.StatusOK {
89+
return fmt.Errorf("download error: status %d", resp.StatusCode)
8890
}
8991
defer resp.Body.Close()
9092
if err := os.MkdirAll(filepath.Dir(dstPath), 0755); err != nil {

0 commit comments

Comments
 (0)