DetectTunnels runs inside every brain_write and brain_update (wikiUpkeep -> AutoTunnel). It walked wiki/ with filepath.WalkDir and opened each note with a blocking os.Open: a FIFO named *.md anywhere under wiki/ hung the write with no deadline, and a symlinked note's title became a tunnel candidate (171k leaks in the swap race). It now walks with brainfs.WalkRegular (regular files only) and reads titles with readTitleAndCreatedIn (ReadRegular: O_NONBLOCK, handle and SameFile checks). A wiki/ that is not a real directory yields no candidates, as filepath.WalkDir did; other walk errors still abort. The path-based readTitleAndCreated, now unused, is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -116,22 +116,6 @@ func collectWingEntries(bfs *brainfs.Brain, wingRel string) ([]noteEntry, error)
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// readTitleAndCreated reads YAML frontmatter for title + created_at; falls
|
||||
// back to slug and file mtime when absent.
|
||||
func readTitleAndCreated(path, slug string) (string, string) {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return slug, ""
|
||||
}
|
||||
defer func() { _ = f.Close() }()
|
||||
title, created := parseTitleAndCreated(f)
|
||||
if created == "" {
|
||||
if info, err := os.Stat(path); err == nil {
|
||||
created = info.ModTime().UTC().Format("2006-01-02")
|
||||
}
|
||||
}
|
||||
return titleOrSlug(title, slug), created
|
||||
}
|
||||
|
||||
// readTitleAndCreatedIn is readTitleAndCreated through the brain root,
|
||||
// regular files only (hyperguild#157).
|
||||
|
||||
Reference in New Issue
Block a user