From fa14a1b9835a46bc9c48c1385b514a0f8d0b4eac Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 7 Jan 2014 11:34:19 -0800 Subject: [PATCH] Only get rootfs when we need to calculate the image size Docker-DCO-1.0-Signed-off-by: Michael Crosby (github: crosbymichael) --- graph.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/graph.go b/graph.go index 058ef7e93d..176626d60a 100644 --- a/graph.go +++ b/graph.go @@ -87,17 +87,17 @@ func (graph *Graph) Get(name string) (*Image, error) { if err != nil { return nil, err } - // Check that the filesystem layer exists - rootfs, err := graph.driver.Get(img.ID) - if err != nil { - return nil, fmt.Errorf("Driver %s failed to get image rootfs %s: %s", graph.driver, img.ID, err) - } if img.ID != id { return nil, fmt.Errorf("Image stored at '%s' has wrong id '%s'", id, img.ID) } img.graph = graph if img.Size < 0 { + rootfs, err := graph.driver.Get(img.ID) + if err != nil { + return nil, fmt.Errorf("Driver %s failed to get image rootfs %s: %s", graph.driver, img.ID, err) + } + var size int64 if img.Parent == "" { if size, err = utils.TreeSize(rootfs); err != nil {