Fix clippy issues

This commit is contained in:
Jai A
2023-03-30 15:18:57 -07:00
parent 80e1ae4553
commit 4875ed4359
16 changed files with 114 additions and 87 deletions

View File

@@ -68,7 +68,7 @@ pub fn get_class_paths_jar<T: AsRef<str>>(
pub fn get_lib_path(libraries_path: &Path, lib: &str) -> crate::Result<String> {
let mut path = libraries_path.to_path_buf();
path.push(get_path_from_artifact(lib.as_ref())?);
path.push(get_path_from_artifact(lib)?);
let path = &path.canonicalize().map_err(|_| {
crate::ErrorKind::LauncherError(format!(
@@ -164,8 +164,7 @@ fn parse_jvm_argument(
))
.as_error()
})?
.to_string_lossy()
.to_string(),
.to_string_lossy(),
)
.replace("${classpath_separator}", classpath_separator())
.replace("${launcher_name}", "theseus")
@@ -219,7 +218,6 @@ pub fn get_minecraft_arguments(
resolution,
)?
.split(' ')
.into_iter()
.map(|x| x.to_string())
.collect())
} else {
@@ -260,8 +258,7 @@ fn parse_minecraft_argument(
))
.as_error()
})?
.to_string_lossy()
.to_owned(),
.to_string_lossy(),
)
.replace(
"${assets_root}",
@@ -274,8 +271,7 @@ fn parse_minecraft_argument(
))
.as_error()
})?
.to_string_lossy()
.to_owned(),
.to_string_lossy(),
)
.replace(
"${game_assets}",
@@ -288,8 +284,7 @@ fn parse_minecraft_argument(
))
.as_error()
})?
.to_string_lossy()
.to_owned(),
.to_string_lossy(),
)
.replace("${version_type}", version_type.as_str())
.replace("${resolution_width}", &resolution.0.to_string())
@@ -366,7 +361,7 @@ pub fn get_processor_arguments<T: AsRef<str>>(
pub async fn get_processor_main_class(
path: String,
) -> crate::Result<Option<String>> {
Ok(tokio::task::spawn_blocking(move || {
tokio::task::spawn_blocking(move || {
let zipfile = std::fs::File::open(&path)?;
let mut archive = zip::ZipArchive::new(zipfile).map_err(|_| {
crate::ErrorKind::LauncherError(format!(
@@ -400,5 +395,5 @@ pub async fn get_processor_main_class(
Ok::<Option<String>, crate::Error>(None)
})
.await
.unwrap()?)
.unwrap()
}

View File

@@ -3,12 +3,14 @@ use async_tungstenite as ws;
use bincode::{Decode, Encode};
use chrono::{prelude::*, Duration};
use futures::prelude::*;
use once_cell::sync::*;
use lazy_static::lazy_static;
use serde::Deserialize;
use url::Url;
pub const HYDRA_URL: Lazy<Url> =
Lazy::new(|| Url::parse("https://hydra.modrinth.com").unwrap());
lazy_static! {
static ref HYDRA_URL: Url =
Url::parse("https://hydra.modrinth.com").unwrap();
}
// Socket messages
#[derive(Deserialize)]
@@ -65,7 +67,7 @@ pub struct HydraAuthFlow<S: AsyncRead + AsyncWrite + Unpin> {
impl HydraAuthFlow<ws::tokio::ConnectStream> {
pub async fn new() -> crate::Result<Self> {
let sock_url = wrap_ref_builder!(
it = HYDRA_URL =>
it = HYDRA_URL.clone() =>
{ it.set_scheme("wss").ok() }
);
let (socket, _) = ws::tokio::connect_async(sock_url.clone()).await?;

View File

@@ -75,7 +75,7 @@ pub async fn download_client(
st: &State,
version_info: &GameVersionInfo,
) -> crate::Result<()> {
let ref version = version_info.id;
let version = &version_info.id;
log::debug!("Locating client for version {version}");
let client_download = version_info
.downloads
@@ -143,7 +143,7 @@ pub async fn download_assets(
stream::iter(index.objects.iter())
.map(Ok::<(&String, &Asset), crate::Error>)
.try_for_each_concurrent(None, |(name, asset)| async move {
let ref hash = asset.hash;
let hash = &asset.hash;
let resource_path = st.directories.object_dir(hash);
let url = format!(
"https://resources.download.minecraft.net/{sub_hash}/{hash}",
@@ -158,7 +158,7 @@ pub async fn download_assets(
let resource = fetch_cell
.get_or_try_init(|| fetch(&url, Some(hash), &permit))
.await?;
write(&resource_path, &resource, &permit).await?;
write(&resource_path, resource, &permit).await?;
log::info!("Fetched asset with hash {hash}");
}
Ok::<_, crate::Error>(())
@@ -172,7 +172,7 @@ pub async fn download_assets(
let resource_path = st.directories.legacy_assets_dir().join(
name.replace('/', &String::from(std::path::MAIN_SEPARATOR))
);
write(&resource_path, &resource, &permit).await?;
write(&resource_path, resource, &permit).await?;
log::info!("Fetched legacy asset with hash {hash}");
}
Ok::<_, crate::Error>(())

View File

@@ -44,6 +44,7 @@ macro_rules! processor_rules {
}
}
#[allow(clippy::too_many_arguments)]
#[tracing::instrument(skip_all, fields(path = ?instance_path))]
pub async fn launch_minecraft(
game_version: &str,
@@ -75,7 +76,7 @@ pub async fn launch_minecraft(
let mut version_info = download::download_version_info(
&state,
&version,
version,
loader_version.as_ref(),
)
.await?;