mirror of
https://github.com/alterware/alterware-launcher.git
synced 2025-12-04 07:17:50 +00:00
chore: some linting
This commit is contained in:
@@ -66,7 +66,7 @@ pub async fn latest_version(
|
||||
let tag = latest_tag(owner, repo, prerelease).await?;
|
||||
let cleaned_tag = tag.replace('v', "");
|
||||
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 {
|
||||
|
||||
@@ -17,18 +17,18 @@ pub async fn quick_request(url: &str) -> Result<String, Box<dyn std::error::Erro
|
||||
.await;
|
||||
|
||||
if let Err(e) = &res {
|
||||
error!("Failed to get {}: {}", url, e);
|
||||
return Err(format!("Failed to get {} {}", url, e).into());
|
||||
error!("Failed to get {url}: {e}");
|
||||
return Err(format!("Failed to get {url} {e}").into());
|
||||
}
|
||||
|
||||
let res = res.unwrap();
|
||||
match res.text().await {
|
||||
Ok(text) => {
|
||||
info!("Successfully received response from: {}", url);
|
||||
info!("Successfully received response from: {url}");
|
||||
Ok(text)
|
||||
}
|
||||
Err(e) => {
|
||||
warn!("Failed to get response text from {}: {}", url, e);
|
||||
warn!("Failed to get response text from {url}: {e}");
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ pub async fn download_file_progress(
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("Failed to GET from '{}': {}", url, e);
|
||||
error!("Failed to GET from '{url}': {e}");
|
||||
format!("Failed to GET from '{url}'")
|
||||
})?;
|
||||
|
||||
@@ -89,14 +89,14 @@ pub async fn get_body(url: &str) -> Result<Vec<u8>, String> {
|
||||
)
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to send request: {}", e))?;
|
||||
.map_err(|e| format!("Failed to send request: {e}"))?;
|
||||
|
||||
debug!("{} {url}", res.status());
|
||||
|
||||
res.bytes()
|
||||
.await
|
||||
.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> {
|
||||
@@ -119,7 +119,7 @@ pub async fn get_json<T: serde::de::DeserializeOwned>(url: &str) -> Result<T, St
|
||||
.header("Accept", "application/json")
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to send request: {}", e))?;
|
||||
.map_err(|e| format!("Failed to send request: {e}"))?;
|
||||
|
||||
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
|
||||
.bytes()
|
||||
.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}"))
|
||||
}
|
||||
|
||||
@@ -763,9 +763,9 @@ async fn main() {
|
||||
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(&install_path.join(format!("{}.exe", client)), &cfg.args);
|
||||
launch(&install_path.join(format!("{client}.exe")), &cfg.args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ pub fn is_program_in_path(program: &str) -> bool {
|
||||
paths.to_str().map(|paths| {
|
||||
paths
|
||||
.split(':')
|
||||
.any(|dir| fs::metadata(format!("{}/{}", dir, program)).is_ok())
|
||||
.any(|dir| fs::metadata(format!("{dir}/{program}")).is_ok())
|
||||
})
|
||||
})
|
||||
.unwrap_or(false)
|
||||
@@ -54,8 +54,8 @@ pub fn is_program_in_path(program: &str) -> bool {
|
||||
paths.to_str().map(|paths| {
|
||||
paths.split(';').any(|dir| {
|
||||
fs::metadata(format!("{}\\{}.exe", dir, program)).is_ok()
|
||||
|| fs::metadata(format!("{}\\{}.cmd", dir, program)).is_ok()
|
||||
|| fs::metadata(format!("{}\\{}.bat", dir, program)).is_ok()
|
||||
|| fs::metadata(format!("{dir}\\{program}.cmd")).is_ok()
|
||||
|| fs::metadata(format!("{dir}\\{program}.bat")).is_ok()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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 {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
error!("Failed to get latest version: {}", e);
|
||||
error!("Failed to get latest version: {e}");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user