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()
|
||||
|
||||
inflatedLayerData, err := archive.DecompressStream(rawTar)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer inflatedLayerData.Close()
|
||||
|
||||
var r io.Reader
|
||||
if progressOutput != nil {
|
||||
fileInfo, err := os.Stat(filename)
|
||||
fileInfo, err := rawTar.Stat()
|
||||
if err != nil {
|
||||
logrus.Debugf("Error statting file: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
progressReader := progress.NewProgressReader(inflatedLayerData, progressOutput, fileInfo.Size(), stringid.TruncateID(id), "Loading layer")
|
||||
|
||||
if ds, ok := l.ls.(layer.DescribableStore); ok {
|
||||
return ds.RegisterWithDescriptor(progressReader, rootFS.ChainID(), foreignSrc)
|
||||
}
|
||||
return l.ls.Register(progressReader, rootFS.ChainID())
|
||||
|
||||
r = progress.NewProgressReader(rawTar, progressOutput, fileInfo.Size(), stringid.TruncateID(id), "Loading layer")
|
||||
} else {
|
||||
r = rawTar
|
||||
}
|
||||
|
||||
inflatedLayerData, err := archive.DecompressStream(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer inflatedLayerData.Close()
|
||||
|
||||
if ds, ok := l.ls.(layer.DescribableStore); ok {
|
||||
return ds.RegisterWithDescriptor(inflatedLayerData, rootFS.ChainID(), foreignSrc)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue