Repository navigation
feat(download): 统一下载中心记录跨脚本更新包诊断信息 - #2030
Conversation
…osing arbitrary files
| except Exception as exc: | ||
| await _write_package_diagnostic( | ||
| destination, url, source=source, downloader=downloader, | ||
| failure=type(exc).__name__, | ||
| ) | ||
| raise | ||
| await _write_package_diagnostic( | ||
| destination, url, source=source, downloader=downloader | ||
| ) |
There was a problem hiding this comment.
Bug: Task cancellation during _write_package_diagnostic inside download_file's exception handler can mask critical exceptions like FluxdownCancelUnconfirmed with CancelledError.
Severity: MEDIUM
Suggested Fix
Shield the diagnostic write with asyncio.shield or guard cancellation around _write_package_diagnostic, ensuring that any CancelledError does not mask or overwrite the original in-flight exception.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: app/core/update.py#L164-L172
Potential issue: In `download_file`, `_write_package_diagnostic` is awaited inside an
`except Exception` handler before re-raising the original exception.
`_write_package_diagnostic` acquires `config_manager.transaction()` and waits on the
global `execution_gate()`. If a task cancellation occurs while waiting for the gate, an
uncaught `asyncio.CancelledError` is raised, replacing the original exception. When
handling `FluxdownWriterUnconfirmed` or `FluxdownCancelUnconfirmed`, this masks the
writer unconfirmed error as a normal task cancellation, which can lead callers like
`script_update_queue.py` to proceed before writer ownership is resolved.
Did we get this right? 👍 / 👎 to inform future reviews.
| await _write_history( | ||
| _utils_fluxdown_cli.FluxdownDownloadRecord( | ||
| url=safe_origin(url), | ||
| destination=str(destination), | ||
| size=int(details.get("bytes") or 0), | ||
| status="diagnostic" if failure is None else "failed", | ||
| error=failure, | ||
| diagnostic=details, | ||
| ) | ||
| ) |
There was a problem hiding this comment.
Bug: Writing extra diagnostic records halves download history retention and causes successful diagnostic records to render as red failure entries in the UI.
Severity: LOW
Suggested Fix
Instead of creating a standalone history record, attach diagnostic metadata to the existing terminal download record or update the UI timeline logic to recognize and color "diagnostic" records appropriately.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: app/core/update.py#L79-L88
Potential issue: Every download attempt writes an additional record with status
`"diagnostic"` on success or `"failed"` on error via `_write_package_diagnostic`.
Because `_write_history` retains only the last 50 entries, this redundant record halves
the effective history capacity. Furthermore, the frontend timeline component in
`DownloadHistorySettings.vue` defaults all non-success/non-fallback statuses to red,
causing successful diagnostic records to display as red failure indicators.
Did we get this right? 👍 / 👎 to inform future reviews.
|
@jinghero review |
… and preserve download exceptions
总体结论:修改后合并取消时保留原始下载异常、把诊断附到终态记录的方向是对的。不过现在会把两次下载尝试拼成一条,排错时反而容易被带偏,喵。 [逻辑 · P2] 不要用一分钟内的同路径记录代替本次下载身份
真实入口是 HSR 的下载重试:同一个 请只合并本次调用实际产生的 FluxDown 终态记录;内置 httpx 每次尝试应单独追加,或沿下载调用传递明确的记录关联。不要仅把匹配记录的状态改成最新值,那仍会抹掉上一次尝试。补一条同目标短间隔“失败后重试成功”的入口回归,确认历史和导出保留各自的状态与诊断。现有四条测试只验证摘要 helper,抓不到这个错配;以上为源码时序核验,未声称运行复现。 dot酱 🐾 |
同步上游 dev,将诊断接到现有下载中心,保留 FluxDown 终态及停写异常。
总体结论:修改后合并
[P2] 大归档的检查限额生效太晚。 先打开 ZIP、读完整目录并统计,再判断条目有没有超限。版本标记的上限也只数成功识别的条目,不限制实际打开多少次。下载已经结束时,诊断还会占着目标文件的锁。建议在解析前先限制目录读取量,再单独限制版本标记的尝试次数;超出就只记格式和大小。 [P2] 新的成功记录也能导出,但导出会把本机路径一并带走。 设置页直接写出整条记录,其中包含本机下载路径和代理信息。这些信息留在本机排查没问题,发给别人时用不着。建议导出时只选必要字段,旧历史也经过同一个出口,不影响本机继续看完整记录。 让诊断少读一点、分享少带一点的 dot酱 |
同步上游 dev,保留每次下载的独立终态记录。
背景
CNB #305 三月七更新包安装后出现嵌套
March7thAssistant目录且版本未变;更新包安装后自动删除,无法复盘归档结构。将通用包诊断放到公共下载入口,而非每个脚本单独记录。改动
app/core/update.py在下载完成、原包仍存在时记录诊断摘要,适用于经公共下载入口的不同脚本及内置 httpx/FluxDown;不会改变下载是否成功的判定。diagnostic,下载历史提供 JSON 导出;诊断 URL 仅保留协议和域名,不含路径、签名参数与凭据。范围
这是统一下载层的第一步:所有经过公共
download_file的脚本均获得包下载诊断;对未接入公共入口的安装器和安装后版本/健康诊断需后续对接适配器。不会将仅下载成功当作安装成功。需等待 CI 验证。