Merge pull request #5058 from ncdc/parallels/fix-new-artifact-visit-when-file-not-found

Parallels: skip missing paths when looking for unnecessary files
This commit is contained in:
Rickard von Essen 2017-06-27 07:09:24 +02:00 committed by GitHub
commit f1d2ae42d8
1 changed files with 8 additions and 0 deletions

View File

@ -29,6 +29,14 @@ func NewArtifact(dir string) (packer.Artifact, error) {
files := make([]string, 0, 5)
visit := func(path string, info os.FileInfo, err error) error {
if err != nil {
if os.IsNotExist(err) {
// It's possible that the path in question existed prior to visit being invoked, but has
// since been deleted. This happens, for example, if you have the VM console open while
// building. Opening the console creates a <vm name>.app directory which is gone by the time
// visit is invoked, resulting in err being a "file not found" error. In this case, skip the
// entire path and continue to the next one.
return filepath.SkipDir
}
return err
}
for _, unnecessaryFile := range unnecessaryFiles {