Browse Source

fix(scanner): continue walk after special files (fixes #9872) (#9877)

We must skip unix sockets, fifos, etc when scanning as these are not
filetypes we can handle. Currently we return a "bug" error, which
results in the walk being aborted and the rest of the tree being
essentially invisible to Syncthing. Instead, just ignore these files and
continue onwards.

This might well be #9859 as well but I can't confirm.
Jakob Borg 10 months ago
parent
commit
79ef57d0ea
1 changed files with 6 additions and 2 deletions
  1. 6 2
      lib/scanner/walk.go

+ 6 - 2
lib/scanner/walk.go

@@ -392,9 +392,13 @@ func (w *walker) handleItem(ctx context.Context, path string, info fs.FileInfo,
 
 	case info.IsRegular():
 		return w.walkRegular(ctx, path, info, toHashChan)
-	}
 
-	return fmt.Errorf("bug: file info for %v is neither symlink, dir nor regular", path)
+	default:
+		// A special file, socket, fifo, etc. -- do nothing but return
+		// success so we continue the walk.
+		l.Debugf("Skipping non-regular file %s (%s)", path, info.Mode())
+		return nil
+	}
 }
 
 func (w *walker) walkRegular(ctx context.Context, relPath string, info fs.FileInfo, toHashChan chan<- protocol.FileInfo) error {