From 9163054d46e560edbeff559a36f40faca45b18ef Mon Sep 17 00:00:00 2001 From: AskaEth Date: Mon, 9 Nov 2026 09:32:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor(presenter):=20=E5=B8=A6=20header=20?= =?UTF-8?q?=E7=9A=84=E8=AF=B7=E6=B1=82=E9=87=8D=E8=AF=95=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=E6=94=B9=E5=BC=95=20core=20=E7=9A=84=E5=8D=95=E4=B8=80?= =?UTF-8?q?=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 台账 §10 第 4 条:http.rs 的 const ATTEMPTS: u32 = 3 是「数字 3 的第二处副本」。 改成引用 unlucky_core::download::config::DEFAULT_MAX_ATTEMPTS_PER_SOURCE(download.retry_limit 的 schema 默认值同源),core 侧一个字未改。 这条带 header 的路径(只有 CurseForge 用)拿不到宿主设置,所以只吃出厂默认——这一点写进了 doc 注释,免得下一个人以为它会跟随用户的 download.retry_limit。 --- crates/presenter/src/host/addon/http.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/presenter/src/host/addon/http.rs b/crates/presenter/src/host/addon/http.rs index f73368e..1655028 100644 --- a/crates/presenter/src/host/addon/http.rs +++ b/crates/presenter/src/host/addon/http.rs @@ -20,6 +20,7 @@ use std::time::Duration; use unlucky_core::download::blocking::block_on; +use unlucky_core::download::config::DEFAULT_MAX_ATTEMPTS_PER_SOURCE; use unlucky_core::download::{DownloadRequest, ResourceKind}; use super::super::env::HostEnv; @@ -29,7 +30,12 @@ pub(super) const USER_AGENT: &str = "Unlucky-Launcher/0.1 (+https://github.com/AskaEth/Unlucky-Launcher)"; /// 最多重试次数(含首次)。 -const ATTEMPTS: u32 = 3; +/// +/// **不在这里写数字**:取值就是下载引擎的出厂默认 +/// (`core::download::config::DEFAULT_MAX_ATTEMPTS_PER_SOURCE`,同一份 schema 默认值 +/// `download.retry_limit`)。这条带 header 的路径拿不到宿主设置,所以只吃出厂默认—— +/// 数字本身只有一处来源,改工厂默认时这里跟着走。 +const ATTEMPTS: u32 = DEFAULT_MAX_ATTEMPTS_PER_SOURCE; /// 取一段文本(JSON 原文)。 pub(super) fn get(env: &HostEnv, url: &str, headers: &[(&str, &str)]) -> Result {