From a23e9c86ba686fb20d0c8be057803d4e85af566e Mon Sep 17 00:00:00 2001 From: greatroar <@> Date: Mon, 9 Mar 2020 14:11:25 +0100 Subject: [PATCH] Remove closing logic from Packer.Finalize The method only ever receives *hashing.Writers, which don't implement io.Closer. These come from packerManager.findPacker and have their actual writers closed in Repository.savePacker. Moving the closing logic to hashing.Writer results in "file already closed" errors. --- internal/pack/pack.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/internal/pack/pack.go b/internal/pack/pack.go index 5bf046304..ce341e1f0 100644 --- a/internal/pack/pack.go +++ b/internal/pack/pack.go @@ -61,8 +61,7 @@ type headerEntry struct { } // Finalize writes the header for all added blobs and finalizes the pack. -// Returned are the number of bytes written, including the header. If the -// underlying writer implements io.Closer, it is closed. +// Returned are the number of bytes written, including the header. func (p *Packer) Finalize() (uint, error) { p.m.Lock() defer p.m.Unlock() @@ -101,11 +100,6 @@ func (p *Packer) Finalize() (uint, error) { bytesWritten += uint(binary.Size(uint32(0))) p.bytes = uint(bytesWritten) - - if w, ok := p.wr.(io.Closer); ok { - return bytesWritten, w.Close() - } - return bytesWritten, nil }