1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Report load progress on compressed layer size

When calling docker load on an image tar containing a compressed layer,
apply NewProgressReader to the compressed layer (whose size is known), not
the uncompressed stream. This fixes progress reporting to the client in
this case.

Signed-off-by: John Starks <jostarks@microsoft.com>
This commit is contained in:
John Starks 2016-06-24 15:15:59 -07:00
parent e8ec19bd87
commit 5fd8edec1c

View file

@ -170,27 +170,24 @@ func (l *tarexporter) loadLayer(filename string, rootFS image.RootFS, id string,
} }
defer rawTar.Close() defer rawTar.Close()
inflatedLayerData, err := archive.DecompressStream(rawTar) var r io.Reader
if err != nil {
return nil, err
}
defer inflatedLayerData.Close()
if progressOutput != nil { if progressOutput != nil {
fileInfo, err := os.Stat(filename) fileInfo, err := rawTar.Stat()
if err != nil { if err != nil {
logrus.Debugf("Error statting file: %v", err) logrus.Debugf("Error statting file: %v", err)
return nil, err return nil, err
} }
progressReader := progress.NewProgressReader(inflatedLayerData, progressOutput, fileInfo.Size(), stringid.TruncateID(id), "Loading layer") r = progress.NewProgressReader(rawTar, progressOutput, fileInfo.Size(), stringid.TruncateID(id), "Loading layer")
} else {
if ds, ok := l.ls.(layer.DescribableStore); ok { r = rawTar
return ds.RegisterWithDescriptor(progressReader, rootFS.ChainID(), foreignSrc)
} }
return l.ls.Register(progressReader, rootFS.ChainID())
inflatedLayerData, err := archive.DecompressStream(r)
if err != nil {
return nil, err
} }
defer inflatedLayerData.Close()
if ds, ok := l.ls.(layer.DescribableStore); ok { if ds, ok := l.ls.(layer.DescribableStore); ok {
return ds.RegisterWithDescriptor(inflatedLayerData, rootFS.ChainID(), foreignSrc) return ds.RegisterWithDescriptor(inflatedLayerData, rootFS.ChainID(), foreignSrc)