diff --git a/httputil/downloadTgzToDir.go b/httputil/downloadTgzToDir.go index 8979d472..05f700f9 100644 --- a/httputil/downloadTgzToDir.go +++ b/httputil/downloadTgzToDir.go @@ -3,6 +3,7 @@ package httputil import ( "archive/tar" "compress/gzip" + "fmt" "io" "net/http" "os" @@ -19,6 +20,10 @@ func DownloadTgzToDir(url, path string) error { } defer res.Body.Close() + if res.StatusCode != http.StatusOK { + return fmt.Errorf("GET %s returned status %d", url, res.StatusCode) + } + if err := os.RemoveAll(path); err != nil { return err }