Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 81d24e754d48ac8e9f0e4fe02befbf628179da43)
... | ... |
@@ -29,6 +29,16 @@ func ValidateContextDirectory(srcPath string, excludes []string) error { |
29 | 29 |
return err |
30 | 30 |
} |
31 | 31 |
return filepath.Walk(contextRoot, func(filePath string, f os.FileInfo, err error) error { |
32 |
+ if err != nil { |
|
33 |
+ if os.IsPermission(err) { |
|
34 |
+ return fmt.Errorf("can't stat '%s'", filePath) |
|
35 |
+ } |
|
36 |
+ if os.IsNotExist(err) { |
|
37 |
+ return nil |
|
38 |
+ } |
|
39 |
+ return err |
|
40 |
+ } |
|
41 |
+ |
|
32 | 42 |
// skip this directory/file if it's not in the path, it won't get added to the context |
33 | 43 |
if relFilePath, err := filepath.Rel(contextRoot, filePath); err != nil { |
34 | 44 |
return err |
... | ... |
@@ -41,16 +51,6 @@ func ValidateContextDirectory(srcPath string, excludes []string) error { |
41 | 41 |
return nil |
42 | 42 |
} |
43 | 43 |
|
44 |
- if err != nil { |
|
45 |
- if os.IsPermission(err) { |
|
46 |
- return fmt.Errorf("can't stat '%s'", filePath) |
|
47 |
- } |
|
48 |
- if os.IsNotExist(err) { |
|
49 |
- return nil |
|
50 |
- } |
|
51 |
- return err |
|
52 |
- } |
|
53 |
- |
|
54 | 44 |
// skip checking if symlinks point to non-existing files, such symlinks can be useful |
55 | 45 |
// also skip named pipes, because they hanging on open |
56 | 46 |
if f.Mode()&(os.ModeSymlink|os.ModeNamedPipe) != 0 { |