Commit f397d0dd by bergquist

fix(cli): retry download when panicing

Will retry to download plugins once if the zip lib panics.

closes #4068
parent 1509b4cb
......@@ -111,7 +111,21 @@ func RemoveGitBuildFromname(pluginname, filename string) string {
return r.ReplaceAllString(filename, pluginname+"/")
}
var retryCount = 0
func downloadFile(pluginName, filepath, url string) (err error) {
defer func() {
if r := recover(); r != nil {
retryCount++
if retryCount == 1 {
log.Debug("\nFailed downloading. Will retry once.\n")
downloadFile(pluginName, filepath, url)
} else {
panic(r)
}
}
}()
resp, err := http.Get(url)
if err != nil {
return err
......@@ -122,12 +136,6 @@ func downloadFile(pluginName, filepath, url string) (err error) {
if err != nil {
return err
}
log.Infof("Got statuscode %s from %s\n", resp.Status, url)
if resp.StatusCode == 302 || resp.StatusCode == 301 {
str, _ := ioutil.ReadAll(resp.Body)
log.Info("body %s\n\n", string(str))
}
r, err := zip.NewReader(bytes.NewReader(body), resp.ContentLength)
if err != nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment