Skip to content

ignore-files.ts: Fix two bugs in ignore-files.ts related to walkFilesRecursive - #4

Merged
codethief merged 2 commits into
masterfrom
fix/recursing_into_tuor_state_dir_and_following_dangling_symlinks
Jun 17, 2026
Merged

ignore-files.ts: Fix two bugs in ignore-files.ts related to walkFilesRecursive#4
codethief merged 2 commits into
masterfrom
fix/recursing_into_tuor_state_dir_and_following_dangling_symlinks

Conversation

@codethief

@codethief codethief commented Jun 17, 2026

Copy link
Copy Markdown
Owner
  • Dangling symlinks would break recursion and cause exception.
  • Recursing into Tuor state dir was semantically incorrect (should never even be mounted in the first place).

walkFilesRecursive followed every symlink with statSync to decide
whether to recurse into it. For a dangling symlink (target missing),
statSync throws ENOENT, which propagated up and aborted the entire
config load.

Guard the statSync call and skip the entry on error instead.

Discovered when the walk recursed into a persistent overlay's upper
layer under .tuor/.state/, which contained a symlink whose target only
resolved inside the sandbox and thus dangled on the host. Not descending
into the state dir is a separate fix; this commit just makes the walk
robust to dangling symlinks in general.
The recursive ignore-file walk started at a mount's host path and
descended into everything below it — including <configDir>/.state, where
Tuor persists overlay upper layers. That state is internal data
(serialized overlay filesystems with whiteout markers and sandbox-only
symlinks), not user content, so scanning it for .tuorignore files is both
wrong and wasteful.

Give walkFiles an excludeDirs parameter (the generic walker stays free of
Tuor-specific knowledge) and have collectIgnorePatterns exclude the state
dir, since that layer knows configDir and owns the ignore-collection
policy.

Centralize the state-dir layout (".state" / "overlays") in a new
state-dir.ts so the path isn't hardcoded in multiple places;
_getOverlayStateDir and init's .gitignore writer now derive from it too.
@codethief
codethief merged commit e8cbd3d into master Jun 17, 2026
4 checks passed
@codethief
codethief deleted the fix/recursing_into_tuor_state_dir_and_following_dangling_symlinks branch June 17, 2026 23:01
codethief added a commit that referenced this pull request Jun 17, 2026
- Dangling symlinks would break recursion and cause exception.
- Recursing into Tuor state dir was semantically incorrect (should never
even be mounted in the first place).
@codethief codethief changed the title ignore-files.ts: Don't follow dangling symlinks, don't recurse into state dir ignore-files.ts: Fix two bugs in ignore-files.ts related to walkFilesRecursive Jun 17, 2026
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.

1 participant