fix(harness): match search-root files for recursive glob in RemoteFilesystem#2344
Closed
logicwu0 wants to merge 1 commit into
Closed
fix(harness): match search-root files for recursive glob in RemoteFilesystem#2344logicwu0 wants to merge 1 commit into
logicwu0 wants to merge 1 commit into
Conversation
…esystem A leading "**/" in a Java glob requires at least one directory separator, so RemoteFilesystem.glob() with patterns like "**/hello.txt" or "**/*.txt" silently skipped files sitting directly at the search root. The direct matcher meant to cover that zero-directory case was built from the raw pattern, so for "**"-prefixed patterns it collapsed into the same recursive matcher and never matched the root file. Strip the leading "**/" when building the direct matcher so it applies to a bare file name at the search root. Covers both the index fast path and the full-scan fallback. Adds regression tests for "**/hello.txt" and "**/*.txt".
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Collaborator
|
Thanks for your contribution. For multiple PRs associated with the same issue, the first one is usually merged. (unless the code quality variance is particularly large) |
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.
问题
Fixes #2342
RemoteFilesystem.glob()用**/hello.txt、**/*.txt这类递归模式时,匹配不到搜索根目录下的文件。例如根下有/hello.txt和/reports/hello.txt,glob("**/hello.txt", "/")只返回/reports/hello.txt。根因
Java glob 里前缀
**/要求至少一个目录分隔符,所以**/hello.txt匹配不到没有/的根层文件名hello.txt。代码本有一个directMatcher用来兜底这种「零层目录」情况,但它是用原始 pattern 构造的——当 pattern 以**开头时,directMatcher塌缩成和matcher完全相同的**/hello.txt,兜底失效。修复
构造
directMatcher时剥掉前导**/,让它以根层裸文件名去匹配。索引快路径和全量扫描兜底两条路径都用到这对 matcher,一处修好覆盖两者。测试
在
FilesystemGlobTest新增两个回归用例(**/hello.txt、**/*.txt)。已验证:未修复时这两个用例复现 issue 症状(根层文件缺失),修复后全部通过,原有用例不受影响。