fix(dlflow): M105 r1 —— 取消后不再逐个派发剩余文件;取消证据补强;取消提示进 i18n
复审三条(p2-3items / fix-then-merge,其中两条按 p1 对待):
**P2-1 取消后仍为每个剩余文件各发一次请求(p1)**
`select` 先轮询左支 ⇒ `install_one` 第一次 poll 就把 `engine.download(…)` 派出去了;
只把标志检查写在右支,等于取消后「每一个剩余 item 都创建并至少 poll 一次」
(一次整文件 sha1 + 一次请求),盘上已就绪的还会第一 poll 就 `Ready` 并回调 `sink`。
修:`async move` 第一句就 `if is_cancelled(cancel) { return None; }`,这些 item 连
`install_one` 都不进。守门用例 `cancelling_mid_run_stops_creating_remaining_files`
(三文件全在盘上、并发 1、sink 首次回调即置标志 ⇒ 数 sink 回调次数):
修后 1,删掉那两行变异后 **3**(见报告,红/绿均实跑)。
模块文档同步改成与实现一致,并把复审点名的固有边界写进注释:取消瞬间最多有
`concurrency`(GUI 传 16)个 future 已经过了那道门,其中「盘上已就绪」的仍会跑完自己的
回调(靠 presenter 的安装代次丢掉这些进度事件),真在下载的会在同一次 poll 被取消。
**P2-3 真网络装置的断言比声称的弱,且有一条探的是恒不成立的路径(p1)**
① `.ullpart` 原来只断言「5 s 后不再增长」⇒「留下一个不增长的非 0 中间文件」会绿;
改成 `assert_eq!(parts_after, 0)`。
② 实例登记原来探 `<game>/instances`(根本不存在 ⇒ 恒 false,什么也没证明);
改成读 `LauncherLayout::profiles_config()` 的 `read_profiles()` 并断言 0 条。
③ 模块文档里那条探针的路径一并订正。
变异自证:留一个 20 字节 `.ullpart` ⇒ 红(`left: 20 / right: 0`);
走真 `instance::register()` 造一条 profile ⇒ 红(`profiles.json 里 1 条实例`)。
**P2-2 取消文案仍是硬编码中文,与新选项区同屏一中一英**
`presenter` 没有 i18n 依赖,所以不是搬常量能解决的。改成发稳定信号:
新增 `CoreEvent::InstallCancelled`(不带文本),`AppState::install_cancelled` 只计数;
app 层在 `refresh_view` 里比对计数、按 `Key::DownloadCancelled` 现求文本弹一次 Toast
(`pages::download::cancelled_toast`)。`dispatch.rs` 的中文 Toast 删掉。
语言入口收成 `app::view::ui_lang()` 一处(现恒为英文;M106 接上语言只改这里,
M106 合并前中文译文在产品路径不可达)。守门:`cancelling_announces_once_in_the_page_language`
(只弹一条、文案来自目录、不含中文、重复 refresh 不重复弹)。
门禁(真实退出码):fmt=0、clippy(--workspace --all-targets -j 2 -D warnings)=0、
`cargo test -p unlucky-app-iced --lib`=0(440 passed)、`cargo test -p unlucky-core`=0、
`cargo test --workspace --exclude unlucky-app -j 2`=0(57 个 target 全 ok,0 failed)。
This commit is contained in:
1 parent
30b1ff6f48
commit
609bcb3044
14 files changed
+240
-23
No files matched your search
@@ -71,6 +71,12 @@ pub enum CoreEvent {
|
||||
JavaChanged(JavaPageView),
|
||||
/// 安装进度(`None` = 清掉进度面板)
|
||||
InstallProgress(Option<InstallProgressView>),
|
||||
/// 用户取消了安装(**不带人读文案**)
|
||||
///
|
||||
/// 为什么只有信号没有文本:`presenter` 不依赖 `unlucky-i18n`,任何写死的中文都会和
|
||||
/// 页面语言打架(下载页目前渲染英文,一条中文 Toast 会**同屏一中一英**,复审 P2-2)。
|
||||
/// 文案由 app 层按 `Key` 现求:见 `pages::download::cancelled_toast`。
|
||||
InstallCancelled,
|
||||
/// 某 (加载器, 原版版本) 可用的加载器版本列表(下载页「安装选项」的版本下拉)。
|
||||
///
|
||||
/// `result` 用 `Result` 而不是空列表:**取不到**与**确实没有**是两件事,
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
//! | 现象 | 怎么量 | 抓住什么 / 抓不住什么 |
|
||||
//! |---|---|---|
|
||||
//! | 进度还在推进 | 取消后收到的 `InstallProgress(Some)` 条数与 `files_done` 增量 | 抓得住「UI 侧还在被事件喂」;抓不住事件之外的后台动作 |
|
||||
//! | 断点文件还在长 | `<game>/**/*.ullpart*` 的总字节,取消时 vs 取消后 20 s | 抓得住「网络/磁盘确实还在写」;抓不住「线程还活着」(`.ullpart` 不再长也可能是卡在等响应) |
|
||||
//! | 实例被登记 | `<game>/versions/<id>/<id>.json` 与 `.minecraft/instances` 有没有多出来 | 抓得住「取消后仍然落了成品」;抓不住「用户看不到的临时目录」 |
|
||||
//! | 断点文件 | `<game>/**/*.ullpart*` 的总字节:取消时 vs 取消后 20 s,**并且**绝对值必须是 0 | 抓得住「还在写」与「留了半截垃圾」;抓不住「线程还活着」(`.ullpart` 不再长也可能是卡在等响应) |
|
||||
//! | 半成品变成品 | `<game>/versions/<id>/<id>.json`(版本清单)与 `<launcher_home>/config/profiles.json`(**实例登记的唯一真相源**,`LauncherLayout::profiles_config()`) | 抓得住「取消后仍然落了成品 / 登记了实例」;抓不住「用户看不到的临时目录」 |
|
||||
//!
|
||||
//! 线程与 socket 两样**抓不住**(没有可移植的查询口,见 `probe` 一节),所以这里不用它当判据。
|
||||
|
||||
@@ -95,6 +95,9 @@ fn real_install_cancel_stops_progress_and_leaves_no_half_product() {
|
||||
|
||||
let env = HostEnv::at_root(&root);
|
||||
let game = env.game.root().to_path_buf();
|
||||
// 实例登记的真相源是 `<launcher_home>/config/profiles.json`(`LauncherLayout::profiles_config()`),
|
||||
// 不是 `<game>/instances` —— 后者根本不存在,探它等于什么都没探(复审 P2-3 第 2 点)。
|
||||
let launcher = env.layout.clone();
|
||||
let mut host = CoreHost::headless(env);
|
||||
|
||||
// ---- 起点:取消之前 ----
|
||||
@@ -193,20 +196,22 @@ fn real_install_cancel_stops_progress_and_leaves_no_half_product() {
|
||||
}
|
||||
|
||||
// ---- 断点文件 / 临时目录 / 成品三样 ----
|
||||
// 版本 JSON 只在「全量就绪」才落盘(`execute` 的 complete 判定),取消后不该有成品;
|
||||
// 实例登记在最后一步之后,取消后不该多出实例。
|
||||
// 版本 JSON 只在「全量就绪」才落盘(`execute` 的 complete 判定);
|
||||
// 实例登记在 `run()` 的最后一步,取消后不该登记(读 profiles.json 这份唯一真相源)。
|
||||
let version_json = game
|
||||
.join("versions")
|
||||
.join(&version)
|
||||
.join(format!("{version}.json"));
|
||||
let profiles = unlucky_core::game::install::instance::read_profiles(&launcher)
|
||||
.expect("profiles.json 应可读(不存在 = 空清单)");
|
||||
eprintln!(
|
||||
"[cancel-test] 版本清单 {} / 实例目录 {}",
|
||||
"[cancel-test] 版本清单{} / profiles.json 里 {} 条实例",
|
||||
if version_json.is_file() {
|
||||
"已落盘"
|
||||
} else {
|
||||
"未落盘"
|
||||
},
|
||||
game.join("instances").is_dir()
|
||||
profiles.profiles.len()
|
||||
);
|
||||
|
||||
// ---- 判据(修好之后必须成立的三条) ----
|
||||
@@ -230,6 +235,15 @@ fn real_install_cancel_stops_progress_and_leaves_no_half_product() {
|
||||
grew, 0,
|
||||
"取消 {settle:?} 之后断点文件还在长(+{grew} 字节):下载没有真的停"
|
||||
);
|
||||
assert_eq!(
|
||||
parts_after, 0,
|
||||
"取消之后还留着 {parts_after} 字节的 `.ullpart`:半截垃圾没清掉(D21 要的就是「清掉或标清楚」)"
|
||||
);
|
||||
assert!(
|
||||
profiles.profiles.is_empty(),
|
||||
"取消之后仍然登记了实例(profiles.json 有 {} 条):半成品被记成成品",
|
||||
profiles.profiles.len()
|
||||
);
|
||||
assert!(
|
||||
!version_json.is_file(),
|
||||
"取消之后仍然落了版本清单:半成品被记成「已安装」"
|
||||
|
||||
@@ -71,7 +71,9 @@ impl CoreHost {
|
||||
self.install_epoch = self.install_epoch.wrapping_add(1);
|
||||
self.install = None;
|
||||
self.send(CoreEvent::InstallProgress(None));
|
||||
self.toast(ToastKind::Info, install::CANCELLED);
|
||||
// 只发信号、不发文案(复审 P2-2):presenter 没有 i18n 依赖,
|
||||
// 写死的中文会和页面语言打架。提示语由 app 层按 `Key` 现求。
|
||||
self.send(CoreEvent::InstallCancelled);
|
||||
}
|
||||
AppCommand::SetIsolation { id, mode } => {
|
||||
match game::set_isolation(&self.env, &id, &mode) {
|
||||
|
||||
@@ -81,6 +81,11 @@ pub struct AppState {
|
||||
pub java: JavaPageView,
|
||||
/// 安装进度(None = 没有安装任务)
|
||||
pub install: Option<InstallProgressView>,
|
||||
/// 用户取消安装的**次数**(M105):每次 `CoreEvent::InstallCancelled` +1。
|
||||
///
|
||||
/// 只是信号,不带文案:app 层比对前后值决定「要不要弹一条 i18n Toast」,
|
||||
/// 于是取消提示和页面用同一种语言(复审 P2-2)。
|
||||
pub install_cancelled: u64,
|
||||
/// 加载器版本清单(下载页「安装选项」的下拉;M105)
|
||||
///
|
||||
/// 两段键:外层是加载器的**稳定 id**(`LoaderKind::as_str`,`LoaderKind` 没派生 `Hash`,
|
||||
@@ -131,6 +136,7 @@ impl AppState {
|
||||
device_login: DeviceLoginView::new(),
|
||||
java: JavaPageView::new(),
|
||||
install: None,
|
||||
install_cancelled: 0,
|
||||
loader_versions: std::collections::HashMap::new(),
|
||||
settings_groups: Vec::new(),
|
||||
settings_tab: "download".to_string(),
|
||||
@@ -245,6 +251,9 @@ impl AppState {
|
||||
}
|
||||
None => self.install = None,
|
||||
},
|
||||
CoreEvent::InstallCancelled => {
|
||||
self.install_cancelled = self.install_cancelled.saturating_add(1);
|
||||
}
|
||||
CoreEvent::SettingsChanged(groups) => self.settings_groups = groups,
|
||||
CoreEvent::LoaderVersions {
|
||||
kind,
|
||||
|
||||
Reference in new issue
Block a user