From 4030a202f8f2eeb20d0ecb547a9d656a8e2821c5 Mon Sep 17 00:00:00 2001 From: Namilskyy Date: Mon, 1 Dec 2025 14:32:31 +0300 Subject: Fixed logical issue in --http repo url --- src/cfg/config.rs | 2 +- src/main.rs | 2 +- src/net/http_package.rs | 21 ++++++++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/cfg/config.rs b/src/cfg/config.rs index af0def3..521ffcc 100644 --- a/src/cfg/config.rs +++ b/src/cfg/config.rs @@ -71,7 +71,7 @@ impl Config { repo_url: format!("https://mesk.anthrill.i2p/repo/{}/", std::env::consts::ARCH), auto_update: true, destination: (String::from("mesk"), String::from("mesk")), - repo_http_url: None, + repo_http_url: format!("http://github.com/Anthrill/repo-mirror/{}", std::env::consts::ARCH).into(), // Its a hurt place, you need to generate destinations by i2pd and paste here (to mesk.toml) // Better to leave it empty or set it to (mesk, mesk), now destination conn not implemented }, diff --git a/src/main.rs b/src/main.rs index 7010d0b..2cff8d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,7 +57,7 @@ struct RemoteInstallArgs { #[arg(help = "Install binary package")] bin: bool, - #[arg(short = 'h', long = "http")] + #[arg(short = 't', long = "http")] #[arg(help = "Use non-i2p mirror")] http: bool, diff --git a/src/net/http_package.rs b/src/net/http_package.rs index aeff588..92b5ffc 100644 --- a/src/net/http_package.rs +++ b/src/net/http_package.rs @@ -40,17 +40,24 @@ impl HTTPPackage { /// /// Returns an error if the request fails, if the response status is not successful, or if there's an issue while reading or writing the file. pub async fn fetch_index_http(&mut self) -> Result> { - let repo_url_str = &self.config.repo.repo_url; + let repo_url_opt = &self.config.repo.repo_http_url; let cache_dir = &self.config.paths.cache_dir; log::debug!("Cache directory: {:?}", cache_dir); - let index_url = if repo_url_str.ends_with(".tar.gz") { - repo_url_str.clone() - } else { - format!("{}/INDEX.tar.gz", repo_url_str.trim_end_matches('/')) - }; - + let index_url = repo_url_opt.as_deref().map_or_else( + || { + log::warn!("Repository URL is None, please specify it in /etc/mesk/mesk.toml and restart."); + String::new() + }, + |repo_url_str| { + if repo_url_str.ends_with(".tar.gz") { + repo_url_str.to_string() + } else { + format!("{}/INDEX.tar.gz", repo_url_str.trim_end_matches('/')) + } + }, + ); let client = reqwest::Client::new(); // Make a HEAD request to get the content length for the progress bar -- cgit v1.2.3