fix(cli): 在 zip 压缩阶段应用 --ignore-dirs 参数过滤指定目录 - #2070
Merged
Merged
Conversation
Previously, the --ignore-dirs parameter was only sent to the server-side for filtering during directory scanning, but the client-side zip compression still included all directories. This caused large dirs like .git and node_modules to be packaged into the zip, potentially exceeding the 512MB upload limit. Changes: - Add parse_ignore_dirs() to parse comma-separated ignore patterns - Add ignore_dirs_filter() to generate walkdir filter_entry closures supporting both basename matching and relative path matching - Add ignore_dirs parameter to zip_directory/zip_directory_with_progress - Pass ignore_dirs from add_resource through to zip functions - Protect root directory from being accidentally pruned - Add 12 unit tests for parse_ignore_dirs and ignore_dirs_filter Fixes: volcengine#2038
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
qin-ctx
approved these changes
May 15, 2026
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.
Description
ov add-resource --ignore-dirs参数此前仅被发送到服务端用于目录扫描阶段的过滤,但客户端 Rust CLI 在 zip 压缩打包阶段仍然将所有目录(包括.git、node_modules等)打包进 zip 文件,导致上传时可能超过 512MB 限制。本次修改在客户端压缩阶段即通过
walkdir::filter_entry剪枝忽略目录,从源头减小 zip 体积。Related Issue
Fixes #2038
Type of Change
Changes Made
parse_ignore_dirs()函数,解析逗号分隔的忽略模式字符串ignore_dirs_filter()函数,生成walkdir::filter_entry闭包,支持 basename 匹配和相对路径匹配(含/的模式)zip_directory和zip_directory_with_progress增加ignore_dirs: Option<&str>参数walkdir遍历中应用filter_entry剪枝忽略目录add_skill调用时传入None,不影响 skill 添加流程Testing
验收结果:
.git和node_modules,原始大小约 32MB--ignore-dirs ".git,node_modules"后,zip 体积缩减至 868B--ignore-dirs时,服务端兜底过滤仍生效(IGNORE_DIRS默认列表)测试过滤掉约一半的文件后,打包上传耗时约减少一半

Checklist
Screenshots (if applicable)
无
Additional Notes
directory_scan.py中的_should_skip_directory保持一致