From 46dd057f5cf2e2f52601fe1f32f96fbae9c791db Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Mon, 2 Nov 2015 11:52:14 -0800 Subject: [PATCH] registry/storage: close filereader after allocation Signed-off-by: Stephen J Day --- registry/storage/blobwriter.go | 1 + registry/storage/blobwriter_resumable.go | 1 + 2 files changed, 2 insertions(+) diff --git a/registry/storage/blobwriter.go b/registry/storage/blobwriter.go index b384fa8a0..3453a57ad 100644 --- a/registry/storage/blobwriter.go +++ b/registry/storage/blobwriter.go @@ -227,6 +227,7 @@ func (bw *blobWriter) validateBlob(ctx context.Context, desc distribution.Descri if err != nil { return distribution.Descriptor{}, err } + defer fr.Close() tr := io.TeeReader(fr, digester.Hash()) diff --git a/registry/storage/blobwriter_resumable.go b/registry/storage/blobwriter_resumable.go index 26d3beab8..d33f544da 100644 --- a/registry/storage/blobwriter_resumable.go +++ b/registry/storage/blobwriter_resumable.go @@ -91,6 +91,7 @@ func (bw *blobWriter) resumeDigestAt(ctx context.Context, offset int64) error { if err != nil { return err } + defer fr.Close() if _, err = fr.Seek(int64(h.Len()), os.SEEK_SET); err != nil { return fmt.Errorf("unable to seek to layer reader offset %d: %s", h.Len(), err)