Re-enabled CmdPull progress bar code which had been temporarily disabled

This commit is contained in:
Solomon Hykes 2013-02-28 16:30:31 -08:00
parent 2192d3371c
commit 5675439b91
1 changed files with 15 additions and 15 deletions

View File

@ -11,7 +11,7 @@ import (
"github.com/dotcloud/docker/image"
"github.com/dotcloud/docker/rcli"
"io"
// "net/http"
"net/http"
"net/url"
"os"
"path"
@ -393,20 +393,20 @@ func (srv *Server) CmdPull(stdin io.ReadCloser, stdout io.Writer, args ...string
fmt.Fprintf(stdout, "Downloading from %s\n", u.String())
// Download with curl (pretty progress bar)
// If curl is not available, fallback to http.Get()
// archive, err := future.Curl(u.String(), stdout)
// if err != nil {
// if resp, err := http.Get(u.String()); err != nil {
// return err
// } else {
// archive = resp.Body
// }
// }
// fmt.Fprintf(stdout, "Unpacking to %s\n", name)
// img, err := srv.images.Import(name, archive, nil)
// if err != nil {
// return err
// }
// fmt.Fprintln(stdout, img.Id)
archive, err := future.Curl(u.String(), stdout)
if err != nil {
if resp, err := http.Get(u.String()); err != nil {
return err
} else {
archive = resp.Body
}
}
fmt.Fprintf(stdout, "Unpacking to %s\n", name)
img, err := srv.images.Import(name, archive, nil)
if err != nil {
return err
}
fmt.Fprintln(stdout, img.Id)
return nil
}