fix(extract): skip _-prefixed directories in walkMarkdownFiles (#202)#209
Open
sharziki wants to merge 1 commit intogarrytan:masterfrom
Open
fix(extract): skip _-prefixed directories in walkMarkdownFiles (#202)#209sharziki wants to merge 1 commit intogarrytan:masterfrom
sharziki wants to merge 1 commit intogarrytan:masterfrom
Conversation
…tan#202) The extract walker matched file-level behavior — `_foo.md` was skipped — but its recursion still walked into `_pending/originals/`, so `gbrain extract all --source fs` counted quarantined pages that the sync path correctly excluded. On a brain with 61 authoritative pages and a sizeable `_pending/` tree, extract reported "154 pages walked" instead of 61, wasting link/timeline extraction effort and producing misleading counts. Hoist the `_`-prefix skip above the `lstatSync` branch so it applies to directories as well. Dotted entries already behave this way. Added a regression test covering a nested `_pending/originals/buried.md` layout alongside a sibling `concepts/alpha.md` that must still be walked. Fixes garrytan#202
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #202 — `gbrain extract all --source fs` walked ``-prefixed directories even though the walker already skipped ``-prefixed files, causing extract to count quarantined content that the sync path correctly excluded.
Root cause
`src/commands/extract.ts::walkMarkdownFiles()`:
```ts
for (const entry of readdirSync(d)) {
if (entry.startsWith('.')) continue; // applies to both files + dirs
const full = join(d, entry);
try {
if (lstatSync(full).isDirectory()) {
walk(full); // recurses into pending/
} else if (entry.endsWith('.md') && !entry.startsWith('')) {
files.push({ path: full, relPath: relative(dir, full) });
}
}
}
```
The `!entry.startsWith('_')` check only gates files. The directory branch above it recurses unconditionally, so `pending/originals/foo.md` is walked even when the user has standardized on ``-prefix quarantine namespaces. On the reporter's brain: 61 authoritative pages but "154 pages walked" once the `_pending/` tree was included.
Fix
Hoist the `_`-prefix skip above the `lstatSync` branch so it behaves the same as the `.`-prefix skip — applies to both files and directories.
```ts
if (entry.startsWith('.')) continue;
if (entry.startsWith('_')) continue;
```
Test plan
🤖 Generated with Claude Code