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

[Finder] Add early directory prunning filter support #50877

Merged
merged 1 commit into from Oct 11, 2023

Conversation

mvorisek
Copy link
Contributor

@mvorisek mvorisek commented Jul 4, 2023

Q A
Branch? 6.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR symfony/symfony-docs#18499

Filtering terminology first:

  • "exclude" - whole filesystem subtree is traversed, directories (and files) are excluded after, slow
  • "prune" - pruned directories are not traversed, fast

Currently there is early directory prunning support possible, but with string patterns only, not even full regex is supported as the input is always quoted - https://github.com/symfony/symfony/blob/v6.2.12/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php#L45.

This PR adds early directory prunning with full callback support.

Tested with VFS to assert the pruned directories are really not traversed and the count of IO syscalls is minimal.

@carsonbot carsonbot added this to the 6.4 milestone Jul 4, 2023
@mvorisek mvorisek force-pushed the finder_exclude_by_callback branch 6 times, most recently from 0117bc0 to 2cb6ad5 Compare July 4, 2023 16:56
@mvorisek mvorisek changed the title Add file finder early directory prunning filter support [Finder] Add early directory prunning filter support Jul 4, 2023
@mvorisek mvorisek force-pushed the finder_exclude_by_callback branch from 2cb6ad5 to c47a9b8 Compare July 6, 2023 08:38
@mvorisek mvorisek force-pushed the finder_exclude_by_callback branch 4 times, most recently from 74945e2 to b5dd592 Compare July 12, 2023 21:16
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Can you expand a bit on the PR description to say what pruning is about in the context of the Finder component? It would help ppl get what this is about more quickly I think.

src/Symfony/Component/Finder/Finder.php Outdated Show resolved Hide resolved
src/Symfony/Component/Finder/Finder.php Outdated Show resolved Hide resolved
@mvorisek mvorisek force-pushed the finder_exclude_by_callback branch 2 times, most recently from 2cdcbf7 to 4864bea Compare July 13, 2023 15:45
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

LGTM, please just use a regular @param annotation for the added argument.

@carsonbot carsonbot changed the title [Finder] Add early directory prunning filter support Add early directory prunning filter support Jul 13, 2023
@mvorisek mvorisek changed the title Add early directory prunning filter support [Finder] Add early directory prunning filter support Jul 29, 2023
@fabpot
Copy link
Member

fabpot commented Oct 11, 2023

@mvorisek Can you rebase to resolve the conflicts?

@nicolas-grekas
Copy link
Member

Thank you @mvorisek.

@nicolas-grekas nicolas-grekas merged commit c868be4 into symfony:6.4 Oct 11, 2023
2 of 9 checks passed
@mvorisek mvorisek deleted the finder_exclude_by_callback branch October 11, 2023 18:08
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Oct 16, 2023
…er support (mvorisek)

This PR was merged into the 6.4 branch.

Discussion
----------

[Finder] [Finder docs] Add early directory prunning filter support

Refs
* symfony/symfony#50877

Commits
-------

4b08ee6 [Finder docs] Add early directory prunning filter support
This was referenced Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants