From 52871c9fc8429caee7113ec149d13c68e30577f5 Mon Sep 17 00:00:00 2001 From: binarybaron <86064887+binarybaron@users.noreply.github.com> Date: Fri, 25 Nov 2022 13:58:44 +0100 Subject: [PATCH] Print update warning correctly formatted --- swap/src/common.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/swap/src/common.rs b/swap/src/common.rs index 66adca83..598d4e72 100644 --- a/swap/src/common.rs +++ b/swap/src/common.rs @@ -9,19 +9,18 @@ pub enum Version { } /// Check the latest release from GitHub API. -pub async fn check_latest_version(current: &str) -> anyhow::Result { +pub async fn check_latest_version(current_version: &str) -> anyhow::Result { let response = reqwest::get(LATEST_RELEASE_URL).await?; let e = "Failed to get latest release."; - let url = response.url(); - let segments = url.path_segments().ok_or_else(|| anyhow!(e))?; - let latest = segments.last().ok_or_else(|| anyhow!(e))?; + let download_url = response.url(); + let segments = download_url.path_segments().ok_or_else(|| anyhow!(e))?; + let latest_version = segments.last().ok_or_else(|| anyhow!(e))?; - let result = if is_latest_version(current, latest) { + let result = if is_latest_version(current_version, latest_version) { Version::Current } else { - println!( - "You are not on the latest version: {} is available. \n{}", - latest, url + tracing::warn!(%current_version, %latest_version, %download_url, + "You are not on the latest version", ); Version::Available };