Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update directory walking to be multithreaded #33

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

giorgiopogliani
Copy link

Hello,

I try to test most cases and it seems that the behaviour is the same or even improved. For example in the excludes now both **/vendor/composer/* and vendor/composer/* works.

Regarding the dir walking:

  • | am using new added jwalk crate which works in async and on mutiple cores.
  • I ignore before walking down directories that starts with a . and node_modules folders. This folder it's something new but I can't really think of a reason why we shouldn't ignore it, it's pretty common, has a huge amount of dirs and files, and it's not PHP.

I am fairly new rust so hopefully this looks good enough

src/source.rs Outdated Show resolved Hide resolved
let entries = jwalk::WalkDir::new(root.clone()).process_read_dir(|_, _, _, children| {
children.iter_mut().for_each(|dir_entry_result| {
if let Ok(dir_entry) = dir_entry_result {
if dir_entry.path().starts_with(".") || dir_entry.file_name.eq_ignore_ascii_case("node_modules") {
Copy link
Member

Choose a reason for hiding this comment

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

we shouldn't ignore node_modules, while usually it does not contain PHP code, it could.

people using node alongside PHP should manually add this to their exclude directory.

Copy link
Author

Choose a reason for hiding this comment

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

What do you mean it could?

Comment on lines +46 to +49
for entry in entries {
if let Err(_) = entry {
continue;
}
Copy link
Member

Choose a reason for hiding this comment

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

we should return the error here instead of ignoring it, if the directory is not readable for example, it should be excluded.

Copy link
Author

@giorgiopogliani giorgiopogliani Dec 26, 2024

Choose a reason for hiding this comment

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

What do you suggest? I wouldn't stop the loop, I would just log the error to the user

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.

2 participants