From d277a4c0f811e86179770f5098b30adf065567c8 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 3 Feb 2014 15:36:06 -0800 Subject: [PATCH 1/2] Do not call Put twice and do not call it on defer Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- image.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image.go b/image.go index b2d7f8eb49..dbd2173597 100644 --- a/image.go +++ b/image.go @@ -163,7 +163,7 @@ func (img *Image) TarLayer() (arch archive.Archive, err error) { } defer func() { - if err == nil { + if err != nil { driver.Put(img.ID) } }() From 02fdc194fc726ef2ce1fa4303e121abd277f8d32 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 3 Feb 2014 15:56:58 -0800 Subject: [PATCH 2/2] Fix unmounts out of container export funcs Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- container.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/container.go b/container.go index 1e44ddd76c..a283b8d0bc 100644 --- a/container.go +++ b/container.go @@ -1416,9 +1416,12 @@ func (container *Container) ExportRw() (archive.Archive, error) { if container.runtime == nil { return nil, fmt.Errorf("Can't load storage driver for unregistered container %s", container.ID) } - defer container.Unmount() - - return container.runtime.Diff(container) + archive, err := container.runtime.Diff(container) + if err != nil { + container.Unmount() + return nil, err + } + return EofReader(archive, func() { container.Unmount() }), nil } func (container *Container) Export() (archive.Archive, error) { @@ -1428,6 +1431,7 @@ func (container *Container) Export() (archive.Archive, error) { archive, err := archive.Tar(container.basefs, archive.Uncompressed) if err != nil { + container.Unmount() return nil, err } return EofReader(archive, func() { container.Unmount() }), nil