diff --git a/script/build.go b/script/build.go index 2c92a5f20..ee0ac4652 100644 --- a/script/build.go +++ b/script/build.go @@ -23,6 +23,7 @@ package main import ( + "errors" "fmt" "io/ioutil" "os" @@ -136,8 +137,14 @@ func date() string { func sourceFilesLaterThan(t time.Time) bool { foundLater := false - _ = filepath.Walk(".", func(path string, info os.FileInfo, err error) error { + err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error { if err != nil { + // Ignore errors that occur when the project contains a symlink to a filesystem or volume that + // Windows doesn't have access to. + if path != "." && isAccessDenied(err) { + fmt.Fprintf(os.Stderr, "%s: %v\n", path, err) + return nil + } return err } if foundLater { @@ -160,9 +167,18 @@ func sourceFilesLaterThan(t time.Time) bool { } return nil }) + if err != nil { + panic(err) + } return foundLater } +func isAccessDenied(err error) bool { + var pe *os.PathError + // we would use `syscall.ERROR_ACCESS_DENIED` if this script supported build tags + return errors.As(err, &pe) && strings.Contains(pe.Err.Error(), "Access is denied") +} + func rmrf(targets ...string) error { args := append([]string{"rm", "-rf"}, targets...) announce(args...)