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:
parent
e8ec19bd87
commit
5fd8edec1c
1 changed files with 11 additions and 14 deletions
|
@ -170,28 +170,25 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue