Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,7 @@ fn infer_count_extensions(
let Ok(rd) = std::fs::read_dir(dir) else {
return;
};
let mut entries: Vec<_> = rd.flatten().collect();
entries.sort_by_key(|e| e.file_name());
for entry in entries {
for entry in rd.flatten() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid holding ReadDir handles during recursion

When inferring file types for a deeply nested tree, iterating rd directly keeps every ancestor ReadDir handle open while the recursive call scans children. The previous collect/sort version drained the directory and dropped that handle before recursing; now a depth near the process file-descriptor limit can make std::fs::read_dir fail with too many open files, which this function silently treats as an unreadable subtree and can return None or the wrong dominant extension, leaving the CLI on the default *.py scope.

Useful? React with πŸ‘Β / πŸ‘Ž.

let Ok(ft) = entry.file_type() else {
continue;
};
Expand Down
Loading