Skip to content

fix(client): 修复单文件在远程server部署时上传失败问题#352

Merged
qin-ctx merged 1 commit intomainfrom
fix/single-file-remote-upload
Feb 28, 2026
Merged

fix(client): 修复单文件在远程server部署时上传失败问题#352
qin-ctx merged 1 commit intomainfrom
fix/single-file-remote-upload

Conversation

@qin-ctx
Copy link
Collaborator

@qin-ctx qin-ctx commented Feb 28, 2026

关联 Issue

Closes #331

变更说明

  • Python HTTP Client (openviking_cli/client/http.py): add_resourceadd_skill 增加 is_file() 分支,单文件直接通过 _upload_temp_file 上传到远程 server
  • Rust CLI Client (crates/ov_cli/src/client.rs): 同上,增加单文件上传分支
  • Rust CLI Config (crates/ov_cli/src/config.rs): 支持 OPENVIKING_CLI_CONFIG_FILE 环境变量,与 Python 侧保持一致
  • Rust CLI Args (crates/ov_cli/src/main.rs): add-resource --timeout 改为可选参数(仅配合 --wait 使用)

问题原因

当 client 和 server 部署在不同机器上时,add-resource 添加单个文件会报 Path xxx does not exist。原因是 client 只把本地文件路径字符串传给了 server,server 在自己的文件系统上找不到该路径。

添加目录时没有这个问题,因为目录场景已经实现了"先 zip 上传再传 temp_path"的逻辑。单文件只需复用同样的上传机制。

修改逻辑

将原有 exists() and is_dir() 判断拆分为三级:

  1. 目录: zip 后上传(原有逻辑不变)
  2. 单文件: 直接上传,server 通过 temp_path 接收
  3. 其他: 传原始路径(原有逻辑不变)

Server 端无需修改,temp_upload 端点已支持接收任意文件。

测试计划

  • Python CLI: 远程 server 下 add-resource 单文件成功
  • Python CLI: 远程 server 下 add-skill 单文件成功
  • Python CLI: 目录上传不受影响(回归)
  • Rust CLI: 远程 server 下 add-resource 单文件成功
  • Rust CLI: 远程 server 下 add-skill 单文件成功
  • Rust CLI: OPENVIKING_CLI_CONFIG_FILE 环境变量生效
  • Rust CLI: --timeout 不传时不报错

🤖 Generated with Claude Code

add-resource/add-skill 添加单个文件到远程 server 时,之前只处理了目录场景
(zip后上传),单文件直接传本地路径导致 server 端报 Path does not exist。

现在对 Python HTTP client 和 Rust CLI client 的 add_resource/add_skill 方法
均增加 is_file() 分支,单文件直接通过 _upload_temp_file 上传。

附带修复:
- Rust CLI config 支持 OPENVIKING_CLI_CONFIG_FILE 环境变量(与 Python 侧一致)
- Rust CLI add-resource --timeout 改为可选参数(仅配合 --wait 使用)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@qin-ctx qin-ctx merged commit 885783e into main Feb 28, 2026
11 checks passed
@qin-ctx qin-ctx deleted the fix/single-file-remote-upload branch February 28, 2026 08:56
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Feb 28, 2026
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Feature]: add resource file by file do not support when client and server deployed in different instance

3 participants