feat(m195): 导入管线取消令牌与原子回滚(取消不是失败)
M190 复核 §3 A-2:导入管线没有取消令牌,「取消导入」只改界面状态,后台仍跑完并写盘
(半包 / 覆盖风险,丢数据档)。本轮把取消做成管线级:
- core 新增 `import/cancel.rs`:`ImportCancel` 令牌(可 `from_flag` 接管既有
`Arc<AtomicBool>`)+ 内部 `Stopped::{Cancelled, Failed}` 两条停止路线;
- 结果类型单列 `ImportStatus::Cancelled`(`error` 恒为 None、退出码 130、文案 key 独立),
与 `Failed` 是两条路——UI 不弹红、脚本不会把「改主意」记成「装坏了」;
- 七个检查点:入口 → 解析后 → 补全后 → 开暂存目录前 → 提交前 → 合并态逐文件 → 登记前;
解压 / 远端下载各逐条检查;单条下载在飞不可中断(fetcher 无取消参数)已在文档里说准;
- 取消后不留半包 / 不覆盖已有实例:暂存目录整个删、合并态 journal 逆序回滚(备份改回原名)、
落盘后取消连内容一起回滚;`files / conflicts / missing / bytes_written` 清零,不留假账;
- presenter:同一个取消标记现在真交给 core(`with_cancel`),取消后不再「后台跑完并登记」;
CLI 增 `cancelled → 130` 一档与三档人读名。
守门三条各带变异证明(见 mission 报告):删回滚 → 红、删登记前检查 → 红、把取消并进
`fail()` → 红。
没验:超大整合包的真实 IO 下取消响应延迟(最坏 = 当前一条文件读完/下完 + 一次回滚)、
单条下载在飞不可中断、macOS / Linux 未跑。
This commit is contained in:
1 parent
3116f43c9f
commit
1441a240fe
18 files changed
+1144
-189
No files matched your search
@@ -100,10 +100,21 @@ const fn reason_of(reason: ConflictReason) -> ConflictReasonView {
|
||||
}
|
||||
|
||||
/// 一次导入结果 → DTO。
|
||||
///
|
||||
/// # `Cancelled` 为什么在这里没有对应档(M195)
|
||||
///
|
||||
/// DTO 的 `ImportStatusView` 只有三档,取消走的是 [`crate::dto::PackEvent::Cancelled`]
|
||||
/// (`import::run` 拿到 `ImportStatus::Cancelled` 就不发报告事件了)。所以本函数只会在
|
||||
/// "取消恰好落在两个检查点之间、报告仍然是成功/部分成功"时被调用。真收到 `Cancelled`
|
||||
/// 时按 `Partial` 落地:**绝不是** `Failed`——取消不是失败,不许画成红的。
|
||||
pub(super) fn report_view(report: &ImportReport, target: &Path) -> ImportReportView {
|
||||
ImportReportView {
|
||||
status: ImportStatusView::from_slug(report.status.as_str())
|
||||
.unwrap_or(ImportStatusView::Failed),
|
||||
status: match report.status {
|
||||
ImportStatus::Cancelled => ImportStatusView::Partial,
|
||||
other => {
|
||||
ImportStatusView::from_slug(other.as_str()).unwrap_or(ImportStatusView::Failed)
|
||||
}
|
||||
},
|
||||
format: report.format.as_deref().and_then(PackFormatView::from_slug),
|
||||
pack_name: report.pack_name.clone(),
|
||||
pack_version: report.pack_version.clone(),
|
||||
|
||||
Reference in new issue
Block a user