refactor(presenter): 带 header 的请求重试次数改引 core 的单一来源
台账 §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。
This commit is contained in:
1 parent
56402d97a1
commit
9163054d46
1 file changed
+7
-1
@@ -20,6 +20,7 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use unlucky_core::download::blocking::block_on;
|
use unlucky_core::download::blocking::block_on;
|
||||||
|
use unlucky_core::download::config::DEFAULT_MAX_ATTEMPTS_PER_SOURCE;
|
||||||
use unlucky_core::download::{DownloadRequest, ResourceKind};
|
use unlucky_core::download::{DownloadRequest, ResourceKind};
|
||||||
|
|
||||||
use super::super::env::HostEnv;
|
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)";
|
"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 原文)。
|
/// 取一段文本(JSON 原文)。
|
||||||
pub(super) fn get(env: &HostEnv, url: &str, headers: &[(&str, &str)]) -> Result<String, String> {
|
pub(super) fn get(env: &HostEnv, url: &str, headers: &[(&str, &str)]) -> Result<String, String> {
|
||||||
|
|||||||
Reference in new issue
Block a user