Browse Source

Merge remote-tracking branch 'origin/progress_bar_push_pull'

Solomon Hykes 12 years ago
parent
commit
47c4c2abd4
1 changed files with 9 additions and 7 deletions
  1. 9 7
      registry.go

+ 9 - 7
registry.go

@@ -136,7 +136,7 @@ func (graph *Graph) getRemoteImage(stdout io.Writer, imgId string, authConfig *a
 	if err != nil {
 		return nil, nil, err
 	}
-	return img, res.Body, nil
+	return img, ProgressReader(res.Body, int(res.ContentLength), stdout), nil
 }
 
 func (graph *Graph) PullImage(stdout io.Writer, imgId string, authConfig *auth.AuthConfig) error {
@@ -268,19 +268,21 @@ func (graph *Graph) PushImage(stdout io.Writer, imgOrig *Image, authConfig *auth
 		// FIXME: Don't do this :D. Check the S3 requierement and implement chunks of 5MB
 		// FIXME2: I won't stress it enough, DON'T DO THIS! very high priority
 		layerData2, err := Tar(path.Join(graph.Root, img.Id, "layer"), Gzip)
-		layerData, err := Tar(path.Join(graph.Root, img.Id, "layer"), Gzip)
+		tmp, err := ioutil.ReadAll(layerData2)
 		if err != nil {
-			return fmt.Errorf("Failed to generate layer archive: %s", err)
+			return err
 		}
-		req3, err := http.NewRequest("PUT", url.String(), layerData)
+		layerLength := len(tmp)
+
+		layerData, err := Tar(path.Join(graph.Root, img.Id, "layer"), Gzip)
 		if err != nil {
-			return err
+			return fmt.Errorf("Failed to generate layer archive: %s", err)
 		}
-		tmp, err := ioutil.ReadAll(layerData2)
+		req3, err := http.NewRequest("PUT", url.String(), ProgressReader(layerData.(io.ReadCloser), layerLength, stdout))
 		if err != nil {
 			return err
 		}
-		req3.ContentLength = int64(len(tmp))
+		req3.ContentLength = int64(layerLength)
 
 		req3.TransferEncoding = []string{"none"}
 		res3, err := client.Do(req3)