When unpacking compressed images that are not compressed as zip archives
(e.g. gzip, xz) the image would unpack nearly all of the way and then
would fail with an error like: 'read |0: file already closed' as is
documented in GitHub issue
61.
As the decompression is offloaded to an external tool for these
compression types and the data is streamed through a reader and writer
in order to allow reporting on progress, we ensure that the exec.Cmd
instance for the external decompression tool is not torn down until the
associated reader is closed. The
docs for Cmd.StdoutPipe
explain this in more detail.
When unpacking compressed images that are not compressed as zip archives (e.g. gzip, xz) the image would unpack nearly all of the way and then would fail with an error like: 'read |0: file already closed' as is documented in GitHub issue 61.
As the decompression is offloaded to an external tool for these compression types and the data is streamed through a reader and writer in order to allow reporting on progress, we ensure that the exec.Cmd instance for the external decompression tool is not torn down until the associated reader is closed. The docs for Cmd.StdoutPipe explain this in more detail.