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

Merge pull request #38413 from slp/master

layer/layer_store: ensure NewInputTarStream resources are released
This commit is contained in:
Yong Tang 2018-12-23 03:43:39 -08:00 committed by GitHub
commit d147fe0582
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -253,13 +253,14 @@ func (ls *layerStore) applyTar(tx *fileMetadataTransaction, ts io.Reader, parent
}
applySize, err := ls.driver.ApplyDiff(layer.cacheID, parent, rdr)
// discard trailing data but ensure metadata is picked up to reconstruct stream
// unconditionally call io.Copy here before checking err to ensure the resources
// allocated by NewInputTarStream above are always released
io.Copy(ioutil.Discard, rdr) // ignore error as reader may be closed
if err != nil {
return err
}
// Discard trailing data but ensure metadata is picked up to reconstruct stream
io.Copy(ioutil.Discard, rdr) // ignore error as reader may be closed
layer.size = applySize
layer.diffID = DiffID(digester.Digest())