You've already forked AstralRinth
forked from didirus/AstralRinth
chore(clippy): enable and fix many stricter lints (#3783)
* chore(clippy): enable and fix many stricter lints These ensure that the codebase uses more idiomatic, performant, and concise language constructions. * chore: make non-Clippy compiler warnings also deny by default
This commit is contained in:
committed by
GitHub
parent
301967d204
commit
f84f8c1c2b
@@ -166,9 +166,8 @@ pub async fn test_jre(
|
||||
path: PathBuf,
|
||||
major_version: u32,
|
||||
) -> crate::Result<bool> {
|
||||
let jre = match jre::check_java_at_filepath(&path).await {
|
||||
Some(jre) => jre,
|
||||
None => return Ok(false),
|
||||
let Some(jre) = jre::check_java_at_filepath(&path).await else {
|
||||
return Ok(false);
|
||||
};
|
||||
let (major, _) = extract_java_majorminor_version(&jre.version)?;
|
||||
Ok(major == major_version)
|
||||
|
||||
@@ -65,8 +65,7 @@ pub async fn import_curseforge(
|
||||
"Curseforge-{}",
|
||||
curseforge_instance_folder
|
||||
.file_name()
|
||||
.map(|a| a.to_string_lossy().to_string())
|
||||
.unwrap_or("Unknown".to_string())
|
||||
.map_or("Unknown".to_string(), |a| a.to_string_lossy().to_string())
|
||||
);
|
||||
|
||||
let state = State::get().await?;
|
||||
|
||||
@@ -52,8 +52,7 @@ pub async fn import_gdlauncher(
|
||||
"GDLauncher-{}",
|
||||
gdlauncher_instance_folder
|
||||
.file_name()
|
||||
.map(|a| a.to_string_lossy().to_string())
|
||||
.unwrap_or("Unknown".to_string())
|
||||
.map_or("Unknown".to_string(), |a| a.to_string_lossy().to_string())
|
||||
);
|
||||
|
||||
// Re-cache icon
|
||||
|
||||
@@ -26,6 +26,7 @@ enum MMCInstanceEnum {
|
||||
struct MMCInstanceGeneral {
|
||||
pub general: MMCInstance,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub struct MMCInstance {
|
||||
@@ -144,9 +145,9 @@ pub async fn is_valid_mmc(instance_folder: PathBuf) -> bool {
|
||||
let instance_cfg = instance_folder.join("instance.cfg");
|
||||
let mmc_pack = instance_folder.join("mmc-pack.json");
|
||||
|
||||
let mmc_pack = match io::read_any_encoding_to_string(&mmc_pack).await {
|
||||
Ok((mmc_pack, _)) => mmc_pack,
|
||||
Err(_) => return false,
|
||||
let Ok((mmc_pack, _)) = io::read_any_encoding_to_string(&mmc_pack).await
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
|
||||
load_instance_cfg(&instance_cfg).await.is_ok()
|
||||
@@ -233,7 +234,7 @@ pub async fn import_mmc(
|
||||
// Kept separate as we may in the future want to add special handling for modrinth managed packs
|
||||
import_mmc_unmanaged(profile_path, minecraft_folder, "Imported Modrinth Modpack".to_string(), description, mmc_pack).await?;
|
||||
}
|
||||
Some(MMCManagedPackType::Flame) | Some(MMCManagedPackType::ATLauncher) => {
|
||||
Some(MMCManagedPackType::Flame | MMCManagedPackType::ATLauncher) => {
|
||||
// For flame/atlauncher managed packs
|
||||
// Treat as unmanaged, but with 'minecraft' folder instead of '.minecraft'
|
||||
import_mmc_unmanaged(profile_path, minecraft_folder, "Imported Modpack".to_string(), description, mmc_pack).await?;
|
||||
|
||||
@@ -357,9 +357,7 @@ pub async fn set_profile_information(
|
||||
}
|
||||
}
|
||||
|
||||
let game_version = if let Some(game_version) = game_version {
|
||||
game_version
|
||||
} else {
|
||||
let Some(game_version) = game_version else {
|
||||
return Err(crate::ErrorKind::InputError(
|
||||
"Pack did not specify Minecraft version".to_string(),
|
||||
)
|
||||
@@ -393,10 +391,7 @@ pub async fn set_profile_information(
|
||||
locked: if !ignore_lock {
|
||||
true
|
||||
} else {
|
||||
prof.linked_data
|
||||
.as_ref()
|
||||
.map(|x| x.locked)
|
||||
.unwrap_or(true)
|
||||
prof.linked_data.as_ref().is_none_or(|x| x.locked)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -152,8 +152,7 @@ pub async fn install_zipped_mrpack_files(
|
||||
if let Some(env) = project.env {
|
||||
if env
|
||||
.get(&EnvType::Client)
|
||||
.map(|x| x == &SideType::Unsupported)
|
||||
.unwrap_or(false)
|
||||
.is_some_and(|x| x == &SideType::Unsupported)
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ pub async fn get_pack_export_candidates(
|
||||
.await
|
||||
.map_err(|e| IOError::with_path(e, &profile_base_dir))?
|
||||
{
|
||||
let path: PathBuf = entry.path();
|
||||
let path = entry.path();
|
||||
if path.is_dir() {
|
||||
// Two layers of files/folders if its a folder
|
||||
let mut read_dir = io::read_dir(&path).await?;
|
||||
@@ -595,10 +595,10 @@ pub async fn get_pack_export_candidates(
|
||||
.await
|
||||
.map_err(|e| IOError::with_path(e, &profile_base_dir))?
|
||||
{
|
||||
let path: PathBuf = entry.path();
|
||||
|
||||
path_list
|
||||
.push(pack_get_relative_path(&profile_base_dir, &path)?);
|
||||
path_list.push(pack_get_relative_path(
|
||||
&profile_base_dir,
|
||||
&entry.path(),
|
||||
)?);
|
||||
}
|
||||
} else {
|
||||
// One layer of files/folders if its a file
|
||||
@@ -669,7 +669,7 @@ pub async fn run_credentials(
|
||||
if let Some(command) = cmd.next() {
|
||||
let full_path = get_full_path(&profile.path).await?;
|
||||
let result = Command::new(command)
|
||||
.args(cmd.collect::<Vec<&str>>())
|
||||
.args(cmd)
|
||||
.current_dir(&full_path)
|
||||
.spawn()
|
||||
.map_err(|e| IOError::with_path(e, &full_path))?
|
||||
@@ -881,15 +881,12 @@ pub async fn create_mrpack_json(
|
||||
env.insert(EnvType::Client, SideType::Required);
|
||||
env.insert(EnvType::Server, SideType::Required);
|
||||
|
||||
let primary_file =
|
||||
if let Some(primary_file) = version.files.first() {
|
||||
primary_file
|
||||
} else {
|
||||
return Some(Err(crate::ErrorKind::OtherError(
|
||||
format!("No primary file found for mod at: {path}"),
|
||||
)
|
||||
.as_error()));
|
||||
};
|
||||
let Some(primary_file) = version.files.first() else {
|
||||
return Some(Err(crate::ErrorKind::OtherError(format!(
|
||||
"No primary file found for mod at: {path}"
|
||||
))
|
||||
.as_error()));
|
||||
};
|
||||
|
||||
let file_size = primary_file.size;
|
||||
let downloads = vec![primary_file.url.clone()];
|
||||
|
||||
@@ -255,7 +255,7 @@ async fn get_all_worlds_in_profile(
|
||||
AttachedWorldData::get_all_for_instance(profile_path, &state.pool)
|
||||
.await?;
|
||||
if !attached_data.is_empty() {
|
||||
for world in worlds.iter_mut() {
|
||||
for world in &mut worlds {
|
||||
if let Some(data) = attached_data
|
||||
.get(&(world.world_type(), world.world_id().to_owned()))
|
||||
{
|
||||
|
||||
@@ -139,9 +139,7 @@ pub async fn edit_loading(
|
||||
// increment refers to by what relative increment to the loading struct's total to update
|
||||
// message is the message to display on the loading bar- if None, use the loading bar's default one
|
||||
// By convention, fraction is the fraction of the progress bar that is filled
|
||||
#[allow(unused_variables)]
|
||||
#[tracing::instrument(level = "debug")]
|
||||
|
||||
pub fn emit_loading(
|
||||
key: &LoadingBarId,
|
||||
increment_frac: f64,
|
||||
@@ -149,22 +147,13 @@ pub fn emit_loading(
|
||||
) -> crate::Result<()> {
|
||||
let event_state = crate::EventState::get()?;
|
||||
|
||||
let mut loading_bar = match event_state.loading_bars.get_mut(&key.0) {
|
||||
Some(f) => f,
|
||||
None => {
|
||||
return Err(EventError::NoLoadingBar(key.0).into());
|
||||
}
|
||||
let Some(mut loading_bar) = event_state.loading_bars.get_mut(&key.0) else {
|
||||
return Err(EventError::NoLoadingBar(key.0).into());
|
||||
};
|
||||
|
||||
// Tick up loading bar
|
||||
loading_bar.current += increment_frac;
|
||||
let display_frac = loading_bar.current / loading_bar.total;
|
||||
let opt_display_frac = if display_frac >= 1.0 {
|
||||
None // by convention, when its done, we submit None
|
||||
// any further updates will be ignored (also sending None)
|
||||
} else {
|
||||
Some(display_frac)
|
||||
};
|
||||
|
||||
if f64::abs(display_frac - loading_bar.last_sent) > 0.005 {
|
||||
// Emit event to indicatif progress bar
|
||||
@@ -187,7 +176,12 @@ pub fn emit_loading(
|
||||
.emit(
|
||||
"loading",
|
||||
LoadingPayload {
|
||||
fraction: opt_display_frac,
|
||||
fraction: if display_frac >= 1.0 {
|
||||
None // by convention, when its done, we submit None
|
||||
// any further updates will be ignored (also sending None)
|
||||
} else {
|
||||
Some(display_frac)
|
||||
},
|
||||
message: message
|
||||
.unwrap_or(&loading_bar.message)
|
||||
.to_string(),
|
||||
@@ -197,6 +191,9 @@ pub fn emit_loading(
|
||||
)
|
||||
.map_err(EventError::from)?;
|
||||
|
||||
#[cfg(not(any(feature = "cli", feature = "tauri")))]
|
||||
let _ = message;
|
||||
|
||||
loading_bar.last_sent = display_frac;
|
||||
}
|
||||
|
||||
@@ -204,8 +201,6 @@ pub fn emit_loading(
|
||||
}
|
||||
|
||||
// emit_warning(message)
|
||||
#[allow(dead_code)]
|
||||
#[allow(unused_variables)]
|
||||
pub async fn emit_warning(message: &str) -> crate::Result<()> {
|
||||
#[cfg(feature = "tauri")]
|
||||
{
|
||||
@@ -227,8 +222,6 @@ pub async fn emit_warning(message: &str) -> crate::Result<()> {
|
||||
// emit_command(CommandPayload::Something { something })
|
||||
// ie: installing a pack, opening an .mrpack, etc
|
||||
// Generally used for url deep links and file opens that we want to handle in the frontend
|
||||
#[allow(dead_code)]
|
||||
#[allow(unused_variables)]
|
||||
pub async fn emit_command(command: CommandPayload) -> crate::Result<()> {
|
||||
tracing::debug!("Command: {}", serde_json::to_string(&command)?);
|
||||
#[cfg(feature = "tauri")]
|
||||
|
||||
@@ -87,9 +87,9 @@ pub fn get_lib_path(
|
||||
lib: &str,
|
||||
allow_not_exist: bool,
|
||||
) -> crate::Result<String> {
|
||||
let mut path = libraries_path.to_path_buf();
|
||||
|
||||
path.push(get_path_from_artifact(lib)?);
|
||||
let path = libraries_path
|
||||
.to_path_buf()
|
||||
.join(get_path_from_artifact(lib)?);
|
||||
|
||||
if !path.exists() && allow_not_exist {
|
||||
return Ok(path.to_string_lossy().to_string());
|
||||
|
||||
@@ -37,12 +37,7 @@ pub async fn download_minecraft(
|
||||
let assets_index =
|
||||
download_assets_index(st, version, Some(loading_bar), force).await?;
|
||||
|
||||
let amount = if version
|
||||
.processors
|
||||
.as_ref()
|
||||
.map(|x| !x.is_empty())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
let amount = if version.processors.as_ref().is_some_and(|x| !x.is_empty()) {
|
||||
25.0
|
||||
} else {
|
||||
40.0
|
||||
|
||||
@@ -17,7 +17,7 @@ use daedalus::modded::LoaderVersion;
|
||||
use regex::Regex;
|
||||
use serde::Deserialize;
|
||||
use st::Profile;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Write;
|
||||
use std::path::PathBuf;
|
||||
use tokio::process::Command;
|
||||
|
||||
@@ -137,8 +137,7 @@ pub async fn get_java_version_from_profile(
|
||||
let key = version_info
|
||||
.java_version
|
||||
.as_ref()
|
||||
.map(|it| it.major_version)
|
||||
.unwrap_or(8);
|
||||
.map_or(8, |it| it.major_version);
|
||||
|
||||
let state = State::get().await?;
|
||||
|
||||
@@ -253,8 +252,7 @@ pub async fn install_minecraft(
|
||||
|
||||
let loader_version_id = loader_version.clone();
|
||||
crate::api::profile::edit(&profile.path, |prof| {
|
||||
prof.loader_version =
|
||||
loader_version_id.clone().map(|x| x.id.clone());
|
||||
prof.loader_version = loader_version_id.clone().map(|x| x.id);
|
||||
|
||||
async { Ok(()) }
|
||||
})
|
||||
@@ -279,8 +277,7 @@ pub async fn install_minecraft(
|
||||
let key = version_info
|
||||
.java_version
|
||||
.as_ref()
|
||||
.map(|it| it.major_version)
|
||||
.unwrap_or(8);
|
||||
.map_or(8, |it| it.major_version);
|
||||
let (java_version, set_java) = if let Some(java_version) =
|
||||
get_java_version_from_profile(profile, &version_info).await?
|
||||
{
|
||||
@@ -631,8 +628,7 @@ pub async fn launch_minecraft(
|
||||
.as_ref()
|
||||
.and_then(|x| x.get(&LoggingSide::Client)),
|
||||
)?
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>(),
|
||||
.into_iter(),
|
||||
)
|
||||
.arg(version_info.main_class.clone())
|
||||
.args(
|
||||
@@ -650,8 +646,7 @@ pub async fn launch_minecraft(
|
||||
&java_version.architecture,
|
||||
quick_play_type,
|
||||
)?
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>(),
|
||||
.into_iter(),
|
||||
)
|
||||
.current_dir(instance_path.clone());
|
||||
|
||||
@@ -695,7 +690,7 @@ pub async fn launch_minecraft(
|
||||
// check if the regex exists in the file
|
||||
if !re.is_match(&options_string) {
|
||||
// The key was not found in the file, so append it
|
||||
options_string.push_str(&format!("\n{key}:{value}"));
|
||||
write!(&mut options_string, "\n{key}:{value}").unwrap();
|
||||
} else {
|
||||
let replaced_string = re
|
||||
.replace_all(&options_string, &format!("{key}:{value}"))
|
||||
@@ -715,31 +710,6 @@ pub async fn launch_minecraft(
|
||||
})
|
||||
.await?;
|
||||
|
||||
let mut censor_strings = HashMap::new();
|
||||
let username = whoami::username();
|
||||
censor_strings
|
||||
.insert(format!("/{username}/"), "/{COMPUTER_USERNAME}/".to_string());
|
||||
censor_strings.insert(
|
||||
format!("\\{username}\\"),
|
||||
"\\{COMPUTER_USERNAME}\\".to_string(),
|
||||
);
|
||||
censor_strings.insert(
|
||||
credentials.access_token.clone(),
|
||||
"{MINECRAFT_ACCESS_TOKEN}".to_string(),
|
||||
);
|
||||
censor_strings.insert(
|
||||
credentials.username.clone(),
|
||||
"{MINECRAFT_USERNAME}".to_string(),
|
||||
);
|
||||
censor_strings.insert(
|
||||
credentials.id.as_simple().to_string(),
|
||||
"{MINECRAFT_UUID}".to_string(),
|
||||
);
|
||||
censor_strings.insert(
|
||||
credentials.id.as_hyphenated().to_string(),
|
||||
"{MINECRAFT_UUID}".to_string(),
|
||||
);
|
||||
|
||||
// If in tauri, and the 'minimize on launch' setting is enabled, minimize the window
|
||||
#[cfg(feature = "tauri")]
|
||||
{
|
||||
|
||||
@@ -461,8 +461,7 @@ impl CacheValue {
|
||||
CacheValue::Team(members) => members
|
||||
.iter()
|
||||
.next()
|
||||
.map(|x| x.team_id.as_str())
|
||||
.unwrap_or(DEFAULT_ID)
|
||||
.map_or(DEFAULT_ID, |x| x.team_id.as_str())
|
||||
.to_string(),
|
||||
CacheValue::Organization(org) => org.id.clone(),
|
||||
CacheValue::File(file) => file.hash.clone(),
|
||||
@@ -556,7 +555,6 @@ macro_rules! impl_cache_methods {
|
||||
$(
|
||||
paste::paste! {
|
||||
#[tracing::instrument(skip(pool, fetch_semaphore))]
|
||||
#[allow(dead_code)]
|
||||
pub async fn [<get_ $variant:snake>](
|
||||
id: &str,
|
||||
cache_behaviour: Option<CacheBehaviour>,
|
||||
@@ -568,7 +566,6 @@ macro_rules! impl_cache_methods {
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(pool, fetch_semaphore))]
|
||||
#[allow(dead_code)]
|
||||
pub async fn [<get_ $variant:snake _many>](
|
||||
ids: &[&str],
|
||||
cache_behaviour: Option<CacheBehaviour>,
|
||||
@@ -597,7 +594,6 @@ macro_rules! impl_cache_method_singular {
|
||||
$(
|
||||
paste::paste! {
|
||||
#[tracing::instrument(skip(pool, fetch_semaphore))]
|
||||
#[allow(dead_code)]
|
||||
pub async fn [<get_ $variant:snake>] (
|
||||
cache_behaviour: Option<CacheBehaviour>,
|
||||
pool: &SqlitePool,
|
||||
@@ -735,18 +731,13 @@ impl CachedEntry {
|
||||
|
||||
remaining_keys.retain(|x| {
|
||||
x != &&*row.id
|
||||
&& !row
|
||||
.alias
|
||||
.as_ref()
|
||||
.map(|y| {
|
||||
if type_.case_sensitive_alias().unwrap_or(true)
|
||||
{
|
||||
x == y
|
||||
} else {
|
||||
y.to_lowercase() == x.to_lowercase()
|
||||
}
|
||||
})
|
||||
.unwrap_or(false)
|
||||
&& !row.alias.as_ref().is_some_and(|y| {
|
||||
if type_.case_sensitive_alias().unwrap_or(true) {
|
||||
x == y
|
||||
} else {
|
||||
y.to_lowercase() == x.to_lowercase()
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
if let Some(data) = parsed_data {
|
||||
@@ -991,7 +982,7 @@ impl CachedEntry {
|
||||
let key = key.to_string();
|
||||
|
||||
if let Some(position) = teams.iter().position(|x| {
|
||||
x.first().map(|x| x.team_id == key).unwrap_or(false)
|
||||
x.first().is_some_and(|x| x.team_id == key)
|
||||
}) {
|
||||
let team = teams.remove(position);
|
||||
|
||||
|
||||
@@ -42,9 +42,8 @@ impl DirectoryInfo {
|
||||
))
|
||||
})?;
|
||||
|
||||
let config_dir = config_dir
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| settings_dir.clone());
|
||||
let config_dir =
|
||||
config_dir.map_or_else(|| settings_dir.clone(), PathBuf::from);
|
||||
|
||||
Ok(Self {
|
||||
settings_dir,
|
||||
@@ -193,8 +192,7 @@ impl DirectoryInfo {
|
||||
let move_dir = settings
|
||||
.custom_dir
|
||||
.as_ref()
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| app_dir.clone());
|
||||
.map_or_else(|| app_dir.clone(), PathBuf::from);
|
||||
|
||||
async fn is_dir_writeable(
|
||||
new_config_dir: &Path,
|
||||
@@ -220,7 +218,7 @@ impl DirectoryInfo {
|
||||
|
||||
let disks = sysinfo::Disks::new_with_refreshed_list();
|
||||
|
||||
for disk in disks.iter() {
|
||||
for disk in &disks {
|
||||
if path.starts_with(disk.mount_point()) {
|
||||
return Ok(Some(disk.available_space()));
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ impl FriendsSocket {
|
||||
ServerToClientMessage::FriendRequest { from } => {
|
||||
let _ = emit_friend(FriendPayload::FriendRequest { from }).await;
|
||||
}
|
||||
ServerToClientMessage::FriendRequestRejected { .. } => todo!(),
|
||||
ServerToClientMessage::FriendRequestRejected { .. } => {}, // TODO
|
||||
|
||||
ServerToClientMessage::FriendSocketListening { .. } => {}, // TODO
|
||||
ServerToClientMessage::FriendSocketStoppedListening { .. } => {}, // TODO
|
||||
|
||||
@@ -29,9 +29,7 @@ where
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
let old_launcher_root = if let Some(dir) = default_settings_dir() {
|
||||
dir
|
||||
} else {
|
||||
let Some(old_launcher_root) = default_settings_dir() else {
|
||||
return Ok(());
|
||||
};
|
||||
let old_launcher_root_str = old_launcher_root.to_string_lossy().to_string();
|
||||
@@ -177,12 +175,10 @@ where
|
||||
|
||||
let profile_path = entry.path().join("profile.json");
|
||||
|
||||
let profile = if let Ok(profile) =
|
||||
let Ok(profile) =
|
||||
read_json::<LegacyProfile>(&profile_path, &io_semaphore)
|
||||
.await
|
||||
{
|
||||
profile
|
||||
} else {
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -285,7 +281,7 @@ where
|
||||
|
||||
TeamMember {
|
||||
team_id: x.team_id,
|
||||
user: user.clone(),
|
||||
user,
|
||||
is_owner: x.role == "Owner",
|
||||
role: x.role,
|
||||
ordering: x.ordering,
|
||||
|
||||
@@ -1154,12 +1154,10 @@ fn get_date_header(headers: &HeaderMap) -> DateTime<Utc> {
|
||||
.get(reqwest::header::DATE)
|
||||
.and_then(|x| x.to_str().ok())
|
||||
.and_then(|x| DateTime::parse_from_rfc2822(x).ok())
|
||||
.map(|x| x.with_timezone(&Utc))
|
||||
.unwrap_or(Utc::now())
|
||||
.map_or(Utc::now(), |x| x.with_timezone(&Utc))
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
#[allow(clippy::format_collect)]
|
||||
fn generate_oauth_challenge() -> String {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
|
||||
@@ -692,7 +692,7 @@ impl Process {
|
||||
let mut cmd = hook.split(' ');
|
||||
if let Some(command) = cmd.next() {
|
||||
let mut command = Command::new(command);
|
||||
command.args(cmd.collect::<Vec<&str>>()).current_dir(
|
||||
command.args(cmd).current_dir(
|
||||
profile::get_full_path(&profile_path).await?,
|
||||
);
|
||||
command.spawn().map_err(IOError::from)?;
|
||||
|
||||
@@ -1022,8 +1022,10 @@ impl Profile {
|
||||
file.hash,
|
||||
file.project_type
|
||||
.filter(|x| *x != ProjectType::Mod)
|
||||
.map(|x| x.get_loaders().join("+"))
|
||||
.unwrap_or_else(|| profile.loader.as_str().to_string()),
|
||||
.map_or_else(
|
||||
|| profile.loader.as_str().to_string(),
|
||||
|x| x.get_loaders().join("+")
|
||||
),
|
||||
profile.game_version
|
||||
)
|
||||
}
|
||||
|
||||
@@ -80,10 +80,9 @@ pub async fn fetch_advanced(
|
||||
) -> crate::Result<Bytes> {
|
||||
let _permit = semaphore.0.acquire().await?;
|
||||
|
||||
let creds = if !header
|
||||
let creds = if header
|
||||
.as_ref()
|
||||
.map(|x| &*x.0.to_lowercase() == "authorization")
|
||||
.unwrap_or(false)
|
||||
.is_none_or(|x| &*x.0.to_lowercase() != "authorization")
|
||||
&& (url.starts_with("https://cdn.modrinth.com")
|
||||
|| url.starts_with(MODRINTH_API_URL)
|
||||
|| url.starts_with(MODRINTH_API_URL_V3))
|
||||
|
||||
@@ -227,13 +227,11 @@ async fn get_all_jre_path() -> HashSet<PathBuf> {
|
||||
paths.unwrap_or_else(|_| HashSet::new())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[allow(dead_code)]
|
||||
pub const JAVA_BIN: &str = "javaw.exe";
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[allow(dead_code)]
|
||||
pub const JAVA_BIN: &str = "java";
|
||||
pub const JAVA_BIN: &str = if cfg!(target_os = "windows") {
|
||||
"javaw.exe"
|
||||
} else {
|
||||
"java"
|
||||
};
|
||||
|
||||
// For each example filepath in 'paths', perform check_java_at_filepath, checking each one concurrently
|
||||
// and returning a JavaVersion for every valid path that points to a java bin
|
||||
@@ -249,7 +247,7 @@ pub async fn check_java_at_filepaths(
|
||||
.collect::<Vec<_>>()
|
||||
.await;
|
||||
|
||||
jres.into_iter().flat_map(|x| x.ok()).flatten().collect()
|
||||
jres.into_iter().filter_map(|x| x.ok()).flatten().collect()
|
||||
}
|
||||
|
||||
// For example filepath 'path', attempt to resolve it and get a Java version at this path
|
||||
|
||||
Reference in New Issue
Block a user