Browse code

builder: fix build cache hash for broken symlink

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>

Tonis Tiigi authored on 2017/07/27 07:26:55
Showing 2 changed files
... ...
@@ -122,8 +122,5 @@ func normalize(path string, root containerfs.ContainerFS) (cleanPath, fullPath s
122 122
 	if err != nil {
123 123
 		return "", "", errors.Wrapf(err, "forbidden path outside the build context: %s (%s)", path, cleanPath)
124 124
 	}
125
-	if _, err := root.Lstat(fullPath); err != nil {
126
-		return "", "", errors.WithStack(convertPathError(err, path))
127
-	}
128 125
 	return
129 126
 }
... ...
@@ -40,14 +40,14 @@ func (c *lazySource) Hash(path string) (string, error) {
40 40
 		return "", err
41 41
 	}
42 42
 
43
-	fi, err := c.root.Lstat(fullPath)
43
+	relPath, err := Rel(c.root, fullPath)
44 44
 	if err != nil {
45
-		return "", errors.WithStack(err)
45
+		return "", errors.WithStack(convertPathError(err, cleanPath))
46 46
 	}
47 47
 
48
-	relPath, err := Rel(c.root, fullPath)
48
+	fi, err := os.Lstat(fullPath)
49 49
 	if err != nil {
50
-		return "", errors.WithStack(convertPathError(err, cleanPath))
50
+		return relPath, nil
51 51
 	}
52 52
 
53 53
 	sum, ok := c.sums[relPath]