From dc1a27fa47c95333d16de1679c9865bdec08b216 Mon Sep 17 00:00:00 2001 From: Hahihula Date: Thu, 11 Jul 2024 16:13:47 +0200 Subject: [PATCH] added additional download mirrors (#10) Co-authored-by: Petr Gadorek --- Cargo.lock | 2 +- src/wizard/mod.rs | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb261ee..6d818db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1779,7 +1779,7 @@ dependencies = [ [[package]] name = "idf-im-lib" version = "0.1.0" -source = "git+https://github.com/espressif/idf-im-lib.git?branch=master#aa8ee079cb2521ead000b2483ea03c67160bd10f" +source = "git+https://github.com/espressif/idf-im-lib.git?branch=master#828fabcb78fb9a8ac092ff248094e9ffe775c9e2" dependencies = [ "colored", "decompress", diff --git a/src/wizard/mod.rs b/src/wizard/mod.rs index f388de6..c561660 100644 --- a/src/wizard/mod.rs +++ b/src/wizard/mod.rs @@ -99,7 +99,12 @@ async fn select_idf_version(target: &str, theme: &ColorfulTheme) -> Result, mirror: Option<&str>) -> Result { +fn download_idf( + path: &str, + tag: Option<&str>, + mirror: Option<&str>, + group_name: Option<&str>, +) -> Result { let _: Result = match idf_im_lib::ensure_path(&path.to_string()) { Ok(_) => Ok("ok".to_string()), Err(err) => return Err(err.to_string()), // probably panic @@ -127,6 +132,7 @@ fn download_idf(path: &str, tag: Option<&str>, mirror: Option<&str>) -> Result Ok("ok".to_string()), @@ -452,7 +458,11 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> { let idf_mirror = match config.idf_mirror { Some(mirror) => mirror, None => { - let mirrors = vec!["https://github.com", "https://jihulab.com/esp-mirror"]; + let mirrors = vec![ + "https://github.com", + "https://jihulab.com/esp-mirror", + "https://gitee.com/", + ]; mirrors[Select::with_theme(&theme) .with_prompt(t!("wizard.idf.mirror")) .items(&mirrors) @@ -462,6 +472,11 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> { .to_string() } }; + let group_name = if idf_mirror.contains("https://gitee.com/") { + Some("EspressifSystems") + } else { + None + }; // download idf let tag = if idf_versions == "master" { None @@ -472,6 +487,7 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> { &idf_path.to_str().unwrap(), tag.as_deref(), Some(&idf_mirror), + group_name, ) { Ok(_) => { debug!("{}", t!("wizard.idf.sucess")); @@ -592,6 +608,7 @@ pub async fn run_wizzard_run(mut config: Settings) -> Result<(), String> { let mirrors = vec![ "https://github.com", "https://dl.espressif.com/github_assets", + "https://dl.espressif.cn/github_assets", ]; mirrors[Select::with_theme(&theme) .with_prompt(t!("wizard.tools.mirror"))