fix(content): 不兼容档在失败路径上取项目名 + 重试轮不再贴错根的标题 (M191 r2)
复审 r2 两条 p2,都修了,并按复审给的口径验过红。
**P2-1(续):不兼容档不再只有裸 id**
`FailureKind::Incompatible` 的项目**确实存在**(站点只是没有匹配目标版本/加载器的条目),
所以失败路径上值得现取一次名字——`plan::names_for_incompatible` 按失败项去重、一项一次 GET
(`Modrinth::project`),`fetch_title` 把任何失败都折成 `None`:
**拿名字失败不许影响安装结果**,取不到 / 拿到空标题就退回 id。只有这一档发请求;
「取不到」档 404 那部分项目根本不存在,再发一次只会再吃 404。
**P2-2(新):重试轮把根的标题贴到了前置头上**
根因是判「这条是不是根项目自己失败」用了 `plan.request.roots.first()`,而重试那一轮的 plan
来自 `retry_request()`,它的 `roots` 就是上一轮的失败名单——第一个是前置。
现在判据改成 **id 比对**(`Root{id,title}`,id 由 `remember` 一起记下来):
`label_of` 只在这条失败的 id 真的等于原始根 id 时才用根的标题。复审给的那个形状
(roots=["P7dR8mSH","1eAoo2KR"] + root_title="Sodium")现在画 `P7dR8mSH`,不再是
`Sodium (P7dR8mSH)`。
**守门(每条都真跑红过,且在拆完模块的最终代码上复跑)**
- 去掉不兼容档的名字来源 ⇒ `an_incompatible_item_shows_the_project_name_once_it_is_known` 红
(`left: "P7dR8mSH"` / `right: "Entity Culling (P7dR8mSH)"`)。
- `label_of` 换回 `roots.first()` ⇒ `the_retry_round_does_not_paste_the_root_title_onto_a_dependency` 红
(`left: ["Sodium (P7dR8mSH)","1eAoo2KR"]`,正是复审实测的那一行)。
- 取名字不降级(`expect`)⇒ `a_failed_name_lookup_falls_back_to_the_id_without_breaking_anything` 红。
**行数**:`plan.rs` 加完这套到 414 行、`install.rs` 到 403 行,都越过 400 硬线 ⇒
把「名字从哪来」整块(`Root`/`Names`/`names_for_incompatible`/`label_of`/`fetch_title`)
纯搬移到 `plan/labels.rs`(111 行):`plan.rs` 336、`install.rs` 388。
This commit is contained in:
1 parent
961ff453a0
commit
26e7b7333e
7 files changed
+313
-77
No files matched your search
@@ -41,7 +41,7 @@ fn retry_failure(instance: &str, catalog: Catalog) -> Option<RetryPanel> {
|
||||
..InstallProgressView::new()
|
||||
};
|
||||
// 三种可显示性各一条,与 host 侧 `plan::label_of` 的三种情况同形:
|
||||
// 根项目 = 请求里的标题、下载失败 = 文件名、解析 404 = 没有名字(只画 id)。
|
||||
// 根项目 = 请求里的标题、下载失败 = 文件名、不兼容档 = 失败路径上现取的项目名。
|
||||
progress.retry = vec![
|
||||
InstallFailureView::new(
|
||||
"AANobbMI",
|
||||
@@ -51,7 +51,7 @@ fn retry_failure(instance: &str, catalog: Catalog) -> Option<RetryPanel> {
|
||||
),
|
||||
InstallFailureView::new(
|
||||
"P7dR8mSH",
|
||||
"",
|
||||
"Entity Culling",
|
||||
InstallFailureKind::Incompatible,
|
||||
"没有匹配所选游戏版本/加载器(1.20.1 / fabric)的版本",
|
||||
),
|
||||
@@ -336,10 +336,10 @@ mod tests {
|
||||
.as_slice()
|
||||
)
|
||||
);
|
||||
// 拿不到名的那一档(解析 404 / 不兼容):只画 id,不编名字
|
||||
// 不兼容档:失败路径上现取的项目名(不是 id)
|
||||
assert_eq!(
|
||||
panel.items_of(unlucky_presenter::dto::InstallFailureKind::Incompatible),
|
||||
Some(["P7dR8mSH".to_string()].as_slice())
|
||||
Some(["Entity Culling (P7dR8mSH)".to_string()].as_slice())
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ fn failed_progress() -> unlucky_presenter::dto::InstallProgressView {
|
||||
),
|
||||
InstallFailureView::new(
|
||||
"P7dR8mSH",
|
||||
"fabric-api.jar",
|
||||
"Entity Culling",
|
||||
InstallFailureKind::Incompatible,
|
||||
"没有匹配的版本",
|
||||
),
|
||||
@@ -52,7 +52,7 @@ fn the_two_tiers_are_two_groups_with_two_labels() {
|
||||
// **P2-1 的守门**:有名字的画「名字 (id)」,没有名字的才只画 id
|
||||
assert_eq!(
|
||||
panel.items_of(InstallFailureKind::Incompatible),
|
||||
Some(["fabric-api.jar (P7dR8mSH)".to_string()].as_slice())
|
||||
Some(["Entity Culling (P7dR8mSH)".to_string()].as_slice())
|
||||
);
|
||||
assert_eq!(
|
||||
panel.items_of(InstallFailureKind::Unreachable),
|
||||
@@ -87,7 +87,7 @@ fn an_empty_tier_does_not_get_a_group() {
|
||||
};
|
||||
progress.retry = vec![InstallFailureView::new(
|
||||
"P7dR8mSH",
|
||||
"fabric-api.jar",
|
||||
"Entity Culling",
|
||||
InstallFailureKind::Incompatible,
|
||||
"没有匹配的版本",
|
||||
)];
|
||||
|
||||
Reference in new issue
Block a user