fix bug where ReadAll on the stderr pipe was causing an infinite hang because there was no stderr to report
This commit is contained in:
parent
9e5b12cbf3
commit
8d5ecb9514
|
@ -246,18 +246,16 @@ func (c *Communicator) Download(src string, dst io.Writer) error {
|
||||||
// enables it to work with directories. We don't actually support
|
// enables it to work with directories. We don't actually support
|
||||||
// directories in Download() but we still need to handle the tar format.
|
// directories in Download() but we still need to handle the tar format.
|
||||||
|
|
||||||
stderrOut, err := ioutil.ReadAll(stderrP)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if string(stderrOut) != "" {
|
|
||||||
return fmt.Errorf("Error downloading file: %s", string(stderrOut))
|
|
||||||
}
|
|
||||||
|
|
||||||
archive := tar.NewReader(pipe)
|
archive := tar.NewReader(pipe)
|
||||||
_, err = archive.Next()
|
_, err = archive.Next()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// see if we can get a useful error message from stderr, since stdout
|
||||||
|
// is messed up.
|
||||||
|
if stderrOut, err := ioutil.ReadAll(stderrP); err == nil {
|
||||||
|
if string(stderrOut) != "" {
|
||||||
|
return fmt.Errorf("Error downloading file: %s", string(stderrOut))
|
||||||
|
}
|
||||||
|
}
|
||||||
return fmt.Errorf("Failed to read header from tar stream: %s", err)
|
return fmt.Errorf("Failed to read header from tar stream: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue