feat(resource): 增加历史 release 与 CAS 复用
bat-rust / Build and test Rust (push) Canceled after 0s
bat-rust / Build and test Go API (push) Canceled after 0s

Closes #47
This commit is contained in:
2026-09-02 01:26:53 +08:00
parent fdd4075e7e
commit bd1e1a06f2
14 changed files with 1235 additions and 59 deletions
+17
View File
@@ -238,6 +238,15 @@ Crowdin 队列当前只落本地文件,不发网络请求。
`--download-concurrency 1`。本文档中的真实资源命令仅是隔离 runbook;本地轻量
验证应使用 fake-curl/fixture,不要在开发机执行真实下载或 smoke run。
新 release 会在网络下载前扫描已发布 release 的下载 manifest,按规范化
destination 查找候选,并重新验证 size、BLAKE3 和 ZIP 结构。命中后优先硬链接,
跨文件系统时回退为 staging 内临时文件复制和原子 rename;历史 release 保持不可变。
历史候选不满足校验时才尝试既有 CAS 对象。CAS 复用会记录
`official-cas-reuse-references.json`,清理 staging/release 时递减引用;损坏、缺失
或元数据不一致会记录诊断并回退网络。报告和进度分别暴露
`release_reused_count``cas_reused_count``reused_bytes`
`transferred_bytes` 以及 `release_reused` / `cas_reused` / `downloaded` 状态。
需要把已校验官方 release 导入 CAS + `ResourceRepository` 时,显式启用:
```bash
@@ -264,6 +273,14 @@ cargo run -p bat-infrastructure --bin bat -- resource-index --limit 50
cargo run -p bat-infrastructure --bin bat -- resource-index --release-id <ID> --platform windows --archive-entry <PATH> --format json --limit 50
```
issue 47 的隔离回归测试:
```bash
cargo test -p bat-infrastructure official_download::tests::reuses_verified_historical_release_when_cdn_root_changes -- --nocapture
cargo test -p bat-infrastructure official_download::tests::falls_back_to_cas_after_corrupt_historical_release -- --nocapture
cargo test -p bat-infrastructure official_download::tests::corrupted_cas_falls_back_to_network_with_diagnostic -- --nocapture
```
`parse-status` 会额外显示 TextUnit 明细索引和队列摘要;`parse-text-units` /
`parse-errors` 可按 destination、archive entry、path id、class id、field path
和 format 分页查询当前官方 release 的 TextUnit 明细与解析错误;