Skip to content

Skip unused broken symlinks #1201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions arduino/builder/sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,15 @@ func SketchLoad(sketchPath, buildPath string) (*sketch.Sketch, error) {
var files []string
rootVisited := false
err = simpleLocalWalk(sketchFolder, maxFileSystemDepth, func(path string, info os.FileInfo, err error) error {
if err != nil {
// Ignore ErrNotExist (broken symlinks), which will be
// reported by os.Open below if the file would not be
// skipped based on the name
if err != nil && !errors.Is(err, os.ErrNotExist) {
feedback.Errorf("Error during sketch processing: %v", err)
os.Exit(errorcodes.ErrGeneric)
}

if info.IsDir() {
if info != nil && info.IsDir() {
// Filters in this if-block are NOT applied to the sketch folder itself.
// Since the sketch folder is the first one processed by simpleLocalWalk,
// we can set the `rootVisited` guard to exclude it.
Expand All @@ -182,7 +185,7 @@ func SketchLoad(sketchPath, buildPath string) (*sketch.Sketch, error) {
}

// ignore hidden files
if strings.HasPrefix(info.Name(), ".") {
if strings.HasPrefix(filepath.Base(path), ".") {
return nil
}

Expand All @@ -197,7 +200,8 @@ func SketchLoad(sketchPath, buildPath string) (*sketch.Sketch, error) {
// check if file is readable
f, err := os.Open(path)
if err != nil {
return nil
feedback.Errorf("Failed to open sketch file: %v", err)
os.Exit(errorcodes.ErrGeneric)
}
f.Close()

Expand Down