diff --git a/updater/fetch.go b/updater/fetch.go index e7e1373..8b7853b 100644 --- a/updater/fetch.go +++ b/updater/fetch.go @@ -50,6 +50,10 @@ func (reg *ResourceRegistry) fetchFile(rv *ResourceVersion, tries int) error { } defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("error fetching url (%s): %s", downloadURL, resp.Status) + } + // download and write file n, err := io.Copy(atomicFile, resp.Body) if err != nil { @@ -96,6 +100,10 @@ func (reg *ResourceRegistry) fetchData(downloadPath string, tries int) ([]byte, } defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("error fetching url (%s): %s", downloadURL, resp.Status) + } + // download and write file buf := bytes.NewBuffer(make([]byte, 0, resp.ContentLength)) n, err := io.Copy(buf, resp.Body)