fix: don't stat negative patterns in static reads - #505
Open
abhu85 wants to merge 1 commit into
Open
Conversation
Static providers passed `task.patterns` (positive patterns plus the negative/ignore patterns re-encoded as `!...`) to the static reader, which lstats each one. For a static pattern combined with an `ignore` pattern this produced an lstat on a bogus path such as `!*.bup.txt`, yielding ENOENT in most environments (silently swallowed) and EIO in some (e.g. Podman/Hyper-V on Windows), where the literal `*` is invalid. Negative patterns are exclusion filters, not paths: ignore handling is already applied via `entryFilter`, which is built from `task.positive` and `task.negative` independently of what is passed to the reader. Pass `task.positive` to the static reader so only real candidate paths are stat'd. Dynamic reads were unaffected. Fixes mrmlnc#499
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of this pull request?
Fixes #499 — for a static pattern combined with an
ignorepattern, fast-glob callslstaton a bogus path such as!*.bup.txt. This is silently swallowed asENOENTin most environments, but surfaces asEIOin some (e.g. Podman/Hyper-V on Windows, where the literal*in the path is invalid).What changes did you make? (Give an overview)
Root cause:
convertPatternGroupToTaskbuildstask.patterns = positive + negative(negatives re-encoded as!...). The static providers passedtask.patternstoreader.static(), whichlstats every entry — including the negative patterns.Fix: pass
task.positiveto the static reader instead oftask.patterns, in all three providers (sync/async/stream). Negative patterns are exclusion filters, not candidate paths —ignorehandling is already applied viaentryFilter, whichProvider#_getReaderOptionsbuilds fromtask.positiveandtask.negativeindependently of what is passed to the reader. So only real candidate paths are now stat'd, and ignore semantics are unchanged. The dynamic path was never affected (it walks the base directory and filters).Tests: added a regression to each provider spec asserting the static reader receives only
task.positive(not the negative patterns). Verified behaviorally thatignorestill excludes static matches (fastGlob.sync("foo.bup.txt", { ignore: ["*.bup.txt"] })→[]).256 passing.CaseSensitiveMatche2e tests fail on case-insensitive filesystems; they involve noignorepatterns.)