From 5103c6279fd0fbb9680033dd14e3858f5081eca0 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Wed, 26 Jul 2017 15:26:55 -0700 Subject: [PATCH] builder: fix build cache hash for broken symlink Signed-off-by: Tonis Tiigi Upstream-commit: 793ebdbf4b187b3680aed0073643040ddbeef523 Component: engine --- components/engine/builder/remotecontext/archive.go | 3 --- components/engine/builder/remotecontext/lazycontext.go | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/components/engine/builder/remotecontext/archive.go b/components/engine/builder/remotecontext/archive.go index fc18c5da31..b62d9dd0b7 100644 --- a/components/engine/builder/remotecontext/archive.go +++ b/components/engine/builder/remotecontext/archive.go @@ -122,8 +122,5 @@ func normalize(path string, root containerfs.ContainerFS) (cleanPath, fullPath s if err != nil { return "", "", errors.Wrapf(err, "forbidden path outside the build context: %s (%s)", path, cleanPath) } - if _, err := root.Lstat(fullPath); err != nil { - return "", "", errors.WithStack(convertPathError(err, path)) - } return } diff --git a/components/engine/builder/remotecontext/lazycontext.go b/components/engine/builder/remotecontext/lazycontext.go index 66f36defd4..14848baa13 100644 --- a/components/engine/builder/remotecontext/lazycontext.go +++ b/components/engine/builder/remotecontext/lazycontext.go @@ -40,16 +40,16 @@ func (c *lazySource) Hash(path string) (string, error) { return "", err } - fi, err := c.root.Lstat(fullPath) - if err != nil { - return "", errors.WithStack(err) - } - relPath, err := Rel(c.root, fullPath) if err != nil { return "", errors.WithStack(convertPathError(err, cleanPath)) } + fi, err := os.Lstat(fullPath) + if err != nil { + return relPath, nil + } + sum, ok := c.sums[relPath] if !ok { sum, err = c.prepareHash(relPath, fi)