Skip to content

fix(harness): match search-root files for recursive glob in RemoteFilesystem#2344

Closed
logicwu0 wants to merge 1 commit into
agentscope-ai:mainfrom
logicwu0:fix/2342-remote-glob-root
Closed

fix(harness): match search-root files for recursive glob in RemoteFilesystem#2344
logicwu0 wants to merge 1 commit into
agentscope-ai:mainfrom
logicwu0:fix/2342-remote-glob-root

Conversation

@logicwu0

Copy link
Copy Markdown
Contributor

问题

Fixes #2342

RemoteFilesystem.glob()**/hello.txt**/*.txt 这类递归模式时,匹配不到搜索根目录下的文件。例如根下有 /hello.txt/reports/hello.txtglob("**/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 症状(根层文件缺失),修复后全部通过,原有用例不受影响。

…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

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jujn

jujn commented Jul 22, 2026

Copy link
Copy Markdown
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)

@jujn jujn closed this Jul 22, 2026
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.

[Bug]:RemoteFilesystem.glob() 使用 **/ 模式时无法匹配搜索目录根层文件

2 participants