fix(local-asr): 修 PR #262 review 提的两个 bug#263
Merged
Conversation
(1) 小文件路径 try_download_range_append 的 retry 污染: 原实现用 append 模式打开 .partial。若上一次 attempt 已写了部分字节后失败, retry 拿到的还是完整 chunk → append → 文件比应有大小多 N 字节,永久损坏。 改成 truncate(effective_start) + seek 写入,每次 attempt 从干净起点重写。 小文件(≤ 32MB)每个 chunk 是整个文件,重写无成本。 (2) 多文件并发一个失败不 abort 其它 worker: 原代码只 log "signaling others to stop",没真 set cancel flag。剩下的 workers 会继续吃带宽直到全部完成才把错误冒上来。 现在错误时主动 cancel.store(true),再用 self_aborted 标记区分这是"我们 因错误 abort"还是"用户主动 cancel"——前者 emit Failed,后者 emit Cancelled, 避免错误被误报成用户取消。 跟踪 PR: #262 review by github-actions PR Reviewer Guide
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
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.
User description
这个 PR 做什么
跟进 PR #262 的 PR Reviewer Guide 提的两个真 bug。
Bug 1 — 小文件 retry 污染
位置:
asr/local/download.rs::try_download_range_append症状:小文件(≤32MB)路径用 append 模式打开
.partial。若上一次 attempt 写了 N 字节后断流,retry 拿到的还是完整 chunk → append →.partial比应有大小多 N 字节,永久损坏且哨兵.openless-asr-ready写完后qwen_load仍会失败。修法:每次 attempt 用
truncate(effective_start) + seek重写,干净起点。小文件每个 chunk 就是整个文件,重写无成本。Bug 2 — 多文件并发一个失败不 abort 其它 worker
位置:
asr/local/download.rs::run_download主 join 循环症状:原代码 "signaling others to stop" 只是 log,没真 set cancel flag。某文件持久失败时,剩下的 worker 继续吃带宽直到全部完成才冒错误,浪费用户几分钟。
修法:错误时主动
cancel.store(true);外层加self_aborted标记区分 "用户主动 cancel" vs "我们因错误自 abort"——前者 emit Cancelled,后者 emit Failed,不会把错误误报成用户取消。Test plan
cargo check全绿🤖 Generated with Claude Code
PR Type
Bug fix
Description
Fix retry corruption on small files by switching from append to truncate+seek
Make any download worker failure immediately abort all parallel workers and report the error
File Walkthrough
download.rs
Fix retry corruption and abort parallel download workers on erroropenless-all/app/src-tauri/src/asr/local/download.rs
try_download_range_append, open the partial file with.write(true)instead of
.append(true), then truncate toeffective_startand seek tothat position before writing the chunk. This prevents file size
inflation when a retry writes the full chunk again over a partially
written file.
run_download, when any per‑file worker fails, set the sharedcancelflag and record
self_aborted = true. The final result now correctlyemits
Failedrather thanCancelled, and other workers stop immediatelyinstead of wasting bandwidth.