Skip to content

feat(load-md-files): replace lstat with glob withFileTypes, eliminate unbounded Promise.all#63

Merged
luojiyin1987 merged 3 commits into
masterfrom
feat/load-md-files-withFileTypes
Jul 5, 2026
Merged

feat(load-md-files): replace lstat with glob withFileTypes, eliminate unbounded Promise.all#63
luojiyin1987 merged 3 commits into
masterfrom
feat/load-md-files-withFileTypes

Conversation

@luojiyin1987

@luojiyin1987 luojiyin1987 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Closes #62

变更

  • load-md-files.ts: 用 glob({ withFileTypes: true }) 重写 — 移除 lstat 引入,模式数组作单次调用,isSymbolicLink() 来自 Dirent(零额外系统调用),fullpath() 获取绝对路径。I/O 从 O(glob 次数) + O(n × lstat) 降至 O(1 次 glob),无 Promise.all 残留。
  • symlink-security.spec.ts: 新增 7 项 loadMdFiles 测试:正常文件、文件符号链接、目录内文件、重复 pattern、相对路径→绝对路径、不存在路径、扩展名过滤
  • sanitize-terminal.ts: ESLint --fix 格式微调

验证

  • 43 项测试通过,lint 和 build 通过
  • load-md-files.ts 行覆盖率 100%(40%→41% 总体)

@luojiyin1987 luojiyin1987 force-pushed the feat/load-md-files-withFileTypes branch from ee5c383 to 017df5f Compare July 5, 2026 14:41
… unbounded Promise.all

- Rewrite loadMdFiles using glob({ withFileTypes: true }) to eliminate all
  lstat system calls — isSymbolicLink() reads Dirent type bits directly
- Pass all patterns as array to single glob() call, removing the first
  Promise.all
- Remove absolute: true (conflicts with withFileTypes), use fullpath()
- Add 6 new tests: normal files, file symlinks, files inside symlinked
  dirs, pattern dedup, relative→absolute paths, nonexistent paths
- Update performance-security-analysis.md: mark P1 as fixed, reorder
  priorities
@luojiyin1987 luojiyin1987 force-pushed the feat/load-md-files-withFileTypes branch from 017df5f to 3b16978 Compare July 5, 2026 14:50
@luojiyin1987 luojiyin1987 merged commit ec155e1 into master Jul 5, 2026
5 checks passed
@luojiyin1987 luojiyin1987 deleted the feat/load-md-files-withFileTypes branch July 5, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

load-md-files: 消除 lstat 系统调用,移除无界 Promise.all

1 participant