diff --git a/rustfs/src/update.rs b/rustfs/src/update.rs index 3b7a267cb..f3316817f 100644 --- a/rustfs/src/update.rs +++ b/rustfs/src/update.rs @@ -59,8 +59,6 @@ pub struct UpdateCheckResult { /// Version checker pub struct VersionChecker { - /// HTTP client - client: reqwest::Client, /// Version server URL version_url: String, /// Request timeout @@ -76,14 +74,7 @@ impl Default for VersionChecker { impl VersionChecker { /// Create a new version checker pub fn new() -> Self { - let client = reqwest::Client::builder() - .timeout(Duration::from_secs(10)) - .user_agent(format!("RustFS/{}", get_current_version())) - .build() - .unwrap_or_else(|_| reqwest::Client::new()); - Self { - client, version_url: "https://version.rustfs.com/latest.json".to_string(), timeout: Duration::from_secs(10), } @@ -91,14 +82,7 @@ impl VersionChecker { /// Create version checker with custom configuration pub fn with_config(url: String, timeout: Duration) -> Self { - let client = reqwest::Client::builder() - .timeout(timeout) - .user_agent(format!("RustFS/{}", get_current_version())) - .build() - .unwrap_or_else(|_| reqwest::Client::new()); - Self { - client, version_url: url, timeout, } @@ -108,9 +92,13 @@ impl VersionChecker { pub async fn check_for_updates(&self) -> Result { let current_version = get_current_version(); debug!("Checking for updates, current version: {}", current_version); + let client = reqwest::Client::builder() + .timeout(self.timeout) + .user_agent(format!("RustFS/{current_version}")) + .build()?; // Send HTTP GET request to get latest version information - let response = self.client.get(&self.version_url).timeout(self.timeout).send().await?; + let response = client.get(&self.version_url).timeout(self.timeout).send().await?; if !response.status().is_success() { let status = response.status(); @@ -182,6 +170,32 @@ pub async fn check_updates_with_url(url: String) -> Result