From 804690bd07dcc1da6d0707d081e40ec9a189a3b6 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 14 Feb 2014 11:33:40 +0100 Subject: [PATCH] archive.TarFilter() - properly close readers CompressStream() now always returns a stream that is closable, and it never closes the underlying writer. TarFilter() makes sure the decompressed stream is closed at the and, as well as the PipeWriter. Docker-DCO-1.1-Signed-off-by: Alexander Larsson (github: alexlarsson) --- archive/archive.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/archive/archive.go b/archive/archive.go index a2b395d4b..dd7dd70b1 100644 --- a/archive/archive.go +++ b/archive/archive.go @@ -106,7 +106,7 @@ func CompressStream(dest io.WriteCloser, compression Compression) (io.WriteClose switch compression { case Uncompressed: - return dest, nil + return utils.NopWriteCloser(dest), nil case Gzip: return gzip.NewWriter(dest), nil case Bzip2, Xz: @@ -337,6 +337,9 @@ func TarFilter(srcPath string, options *TarOptions) (io.Reader, error) { if err := compressWriter.Close(); err != nil { utils.Debugf("Can't close compress writer: %s\n", err) } + if err := pipeWriter.Close(); err != nil { + utils.Debugf("Can't close pipe writer: %s\n", err) + } }() return pipeReader, nil