fix(linkcheck): skip a linked tree that is not a real directory (#157)
Review round 1 on PR #175: - entryIndex returned WalkRegular's walk-root ErrNotRegular as an error, and StripUnresolvedLinks runs before every brain_write: a symlinked, dangling or regular-file knowledge/ (or wiki/) made every write fail and lose the learning. main's filepath.WalkDir skipped such a root. It is now skipped with a warning; other walk errors still abort, as on main. New table test over the three shapes. - The symlinked-hall assertion passed with no index written at all. It now indexes a real hall next to the symlinked one and asserts no error, the index exists and lists the real note; a new test does the same for BuildAllWingIndexes with a symlinked wing next to a real one. - The test comment no longer says this PR fixed the FIFO hang on every brain_write: that path is tunnel.DetectTunnels (slice 5b). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log/slog"
|
||||
"path"
|
||||
"regexp"
|
||||
"sort"
|
||||
@@ -121,6 +122,13 @@ func entryIndex(brainDir string) (map[string]struct{}, error) {
|
||||
index[strings.TrimPrefix(strings.TrimSuffix(rel, ".md"), "wiki/")] = struct{}{}
|
||||
return nil
|
||||
}, func(rel string, err error) {
|
||||
// A linked tree that is not a real directory (a symlink, a
|
||||
// file) is skipped, as filepath.WalkDir did: this runs before
|
||||
// every brain_write, and an error here loses the learning.
|
||||
if rel == dir && errors.Is(err, brainfs.ErrNotRegular) {
|
||||
slog.Warn("link check: skipping a linked tree that is not a real directory", "dir", dir)
|
||||
return
|
||||
}
|
||||
if walkErr == nil {
|
||||
walkErr = fmt.Errorf("%s: %w", rel, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user