chore: some linting

This commit is contained in:
alterware
2025-07-03 10:27:52 +02:00
parent 27795f6680
commit 2dab50111b
6 changed files with 17 additions and 17 deletions

View File

@@ -66,7 +66,7 @@ pub async fn latest_version(
let tag = latest_tag(owner, repo, prerelease).await?; let tag = latest_tag(owner, repo, prerelease).await?;
let cleaned_tag = tag.replace('v', ""); let cleaned_tag = tag.replace('v', "");
Version::parse(&cleaned_tag) Version::parse(&cleaned_tag)
.map_err(|e| format!("Failed to parse version '{}': {}", cleaned_tag, e).into()) .map_err(|e| format!("Failed to parse version '{cleaned_tag}': {e}").into())
} }
pub fn download_url(owner: &str, repo: &str, tag: Option<&str>) -> String { pub fn download_url(owner: &str, repo: &str, tag: Option<&str>) -> String {

View File

@@ -17,18 +17,18 @@ pub async fn quick_request(url: &str) -> Result<String, Box<dyn std::error::Erro
.await; .await;
if let Err(e) = &res { if let Err(e) = &res {
error!("Failed to get {}: {}", url, e); error!("Failed to get {url}: {e}");
return Err(format!("Failed to get {} {}", url, e).into()); return Err(format!("Failed to get {url} {e}").into());
} }
let res = res.unwrap(); let res = res.unwrap();
match res.text().await { match res.text().await {
Ok(text) => { Ok(text) => {
info!("Successfully received response from: {}", url); info!("Successfully received response from: {url}");
Ok(text) Ok(text)
} }
Err(e) => { Err(e) => {
warn!("Failed to get response text from {}: {}", url, e); warn!("Failed to get response text from {url}: {e}");
Err(e.into()) Err(e.into())
} }
} }

View File

@@ -32,7 +32,7 @@ pub async fn download_file_progress(
.send() .send()
.await .await
.map_err(|e| { .map_err(|e| {
error!("Failed to GET from '{}': {}", url, e); error!("Failed to GET from '{url}': {e}");
format!("Failed to GET from '{url}'") format!("Failed to GET from '{url}'")
})?; })?;
@@ -89,14 +89,14 @@ pub async fn get_body(url: &str) -> Result<Vec<u8>, String> {
) )
.send() .send()
.await .await
.map_err(|e| format!("Failed to send request: {}", e))?; .map_err(|e| format!("Failed to send request: {e}"))?;
debug!("{} {url}", res.status()); debug!("{} {url}", res.status());
res.bytes() res.bytes()
.await .await
.map(|b| b.to_vec()) .map(|b| b.to_vec())
.map_err(|e| format!("Failed to get body: {}", e)) .map_err(|e| format!("Failed to get body: {e}"))
} }
pub async fn get_body_string(url: &str) -> Result<String, String> { pub async fn get_body_string(url: &str) -> Result<String, String> {
@@ -119,7 +119,7 @@ pub async fn get_json<T: serde::de::DeserializeOwned>(url: &str) -> Result<T, St
.header("Accept", "application/json") .header("Accept", "application/json")
.send() .send()
.await .await
.map_err(|e| format!("Failed to send request: {}", e))?; .map_err(|e| format!("Failed to send request: {e}"))?;
debug!("{} {}", res.status(), url); debug!("{} {}", res.status(), url);
@@ -130,7 +130,7 @@ pub async fn get_json<T: serde::de::DeserializeOwned>(url: &str) -> Result<T, St
let body = res let body = res
.bytes() .bytes()
.await .await
.map_err(|e| format!("Failed to read response body: {}", e))?; .map_err(|e| format!("Failed to read response body: {e}"))?;
serde_json::from_slice::<T>(&body).map_err(|e| format!("Failed to parse JSON: {}", e)) serde_json::from_slice::<T>(&body).map_err(|e| format!("Failed to parse JSON: {e}"))
} }

View File

@@ -763,9 +763,9 @@ async fn main() {
std::process::exit(1); std::process::exit(1);
}; };
info!("Launching game in offline mode with client: {}", client); info!("Launching game in offline mode with client: {client}");
// Launch game without updates // Launch game without updates
launch(&install_path.join(format!("{}.exe", client)), &cfg.args); launch(&install_path.join(format!("{client}.exe")), &cfg.args);
return; return;
} }

View File

@@ -41,7 +41,7 @@ pub fn is_program_in_path(program: &str) -> bool {
paths.to_str().map(|paths| { paths.to_str().map(|paths| {
paths paths
.split(':') .split(':')
.any(|dir| fs::metadata(format!("{}/{}", dir, program)).is_ok()) .any(|dir| fs::metadata(format!("{dir}/{program}")).is_ok())
}) })
}) })
.unwrap_or(false) .unwrap_or(false)
@@ -54,8 +54,8 @@ pub fn is_program_in_path(program: &str) -> bool {
paths.to_str().map(|paths| { paths.to_str().map(|paths| {
paths.split(';').any(|dir| { paths.split(';').any(|dir| {
fs::metadata(format!("{}\\{}.exe", dir, program)).is_ok() fs::metadata(format!("{}\\{}.exe", dir, program)).is_ok()
|| fs::metadata(format!("{}\\{}.cmd", dir, program)).is_ok() || fs::metadata(format!("{dir}\\{program}.cmd")).is_ok()
|| fs::metadata(format!("{}\\{}.bat", dir, program)).is_ok() || fs::metadata(format!("{dir}\\{program}.bat")).is_ok()
}) })
}) })
}) })

View File

@@ -15,7 +15,7 @@ pub async fn self_update_available(prerelease: Option<bool>) -> bool {
let latest_version = match github::latest_version(GH_OWNER, GH_REPO, prerelease).await { let latest_version = match github::latest_version(GH_OWNER, GH_REPO, prerelease).await {
Ok(v) => v, Ok(v) => v,
Err(e) => { Err(e) => {
error!("Failed to get latest version: {}", e); error!("Failed to get latest version: {e}");
return false; return false;
} }
}; };