feat(board): share files over session HTTP - #158
Merged
Conversation
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.
问题
现有 board session 文件只能通过控制 API 管理,并依赖 TFTP 提供板端访问。测试用例无法在任意 boot mode 下把临时脚本按原相对路径共享给开发板,也无法获得板端网络可访问的服务地址。
修改
GET /share/sessions/{session_id}/{relative_path},支持完整与单段 Range 下载;session 释放、超时或进入 releasing 后立即返回 404。http_url,boot profile 新增板端可达的http_base_url;HTTP/TFTP URL 均通过url::Url构造与 Serde 编解码。BoardSessionContext、BoardSession::context()、BoardSession::upload_shared_file()和BoardRunRequest。session_files保留相对于配置目录的原路径,不提供 alias 或上传改名;拒绝绝对路径、..、符号链接逃逸、重复路径和缺失文件。${boardServerIp}、${boardServerHttpBaseUrl}和${sessionFile:<relative-path>},普通 shell 变量保持原样;任一准备或运行失败仍进入 session release 流程。FileResponse类型别名兼容已有调用方。实现逻辑
服务端从已解析的板端网络配置生成共享 HTTP URL,URL 路径段由
UrlAPI 编码。共享下载端点只允许访问活动 session,并从同一 session 存储读取文件,因此租约和清理状态是唯一生命周期来源。客户端先验证本地相对路径边界,再分配 session、获取板端网络上下文、逐文件上传和展开保留变量。没有共享文件或 session 变量的旧调用路径不会请求新字段,可继续连接旧服务端。
验证
cargo test -p ostool -p ostool-server --no-fail-fastcargo clippy -p ostool -p ostool-server --all-targets -- -D warnings