mirror of
https://github.com/openai/codex.git
synced 2026-10-27 00:00:53 +00:00
fs: support pruning hidden directories during walks (#31570)
Why Filtering hidden directories after a walk is too late: their descendants consume traversal limits, and canonical directory deduplication can let a hidden path claim a target before a visible symlink reaches it. What this changes - Add an optional pruneHiddenDirectories walk option. It defaults to false and is omitted from the wire when disabled. - Return hidden directory entries, but do not traverse them or add their canonical identities to the visited set. - Cover the visible-symlink-to-hidden-directory case through both local and remote filesystem implementations. This is the small filesystem prerequisite for #31566. Skill-specific behavior remains in that PR.
This commit is contained in:
@@ -81,6 +81,9 @@ pub struct WalkOptions {
|
||||
pub max_entries: usize,
|
||||
/// Whether directory symlinks should be followed.
|
||||
pub follow_directory_symlinks: bool,
|
||||
/// Whether directories whose names start with `.` should be returned but not traversed.
|
||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||
pub prune_hidden_directories: bool,
|
||||
}
|
||||
|
||||
/// Type of a filesystem entry returned by a walk.
|
||||
@@ -463,6 +466,9 @@ async fn walk_via_directory_reads<F: ExecutorFileSystem + ?Sized>(
|
||||
});
|
||||
|
||||
if kind == WalkEntryKind::Directory && depth < options.max_depth {
|
||||
if options.prune_hidden_directories && entry.file_name.starts_with('.') {
|
||||
continue;
|
||||
}
|
||||
let directory_identity = if options.follow_directory_symlinks {
|
||||
match file_system.canonicalize(&path, sandbox).await {
|
||||
Ok(path) => path,
|
||||
|
||||
Reference in New Issue
Block a user