diff options
Diffstat (limited to 'src/net')
| -rw-r--r-- | src/net/http_package.rs | 21 |
1 files changed, 14 insertions, 7 deletions
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<bool, Box<dyn std::error::Error>> { - 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 |
