diff --git a/common/src/finder/pdlauncher.rs b/common/src/finder/pdlauncher.rs index a85a9a2..f5c80a1 100644 --- a/common/src/finder/pdlauncher.rs +++ b/common/src/finder/pdlauncher.rs @@ -13,7 +13,7 @@ impl PDLauncherInstallFinder { .join("Kerbal Space Program 2"); if default_install_folder.exists() { - return Some(default_install_folder.to_path_buf()); + return Some(default_install_folder); } return None; @@ -31,7 +31,7 @@ impl PDLauncherInstallFinder { .join("Kerbal Space Program"); if default_install_folder.exists() { - return Some(default_install_folder.to_path_buf()); + return Some(default_install_folder); } return None; diff --git a/common/src/installer/mods.rs b/common/src/installer/mods.rs index 86688b8..fb11cf5 100644 --- a/common/src/installer/mods.rs +++ b/common/src/installer/mods.rs @@ -4,7 +4,7 @@ use std::{ path::PathBuf, }; -use crate::{mods::spacedock::SpaceDockAPI, util::copy_dir_all}; +use crate::{instances::KSPGame, mods::spacedock::SpaceDockAPI, util::copy_dir_all}; pub struct ModInstaller { pub install_path: PathBuf, @@ -29,7 +29,7 @@ impl ModInstaller { .expect("Could not create the mod file!"); io::copy(&mut body.as_ref(), &mut out_file).expect("Could not copy the mod to the file!"); - + let mod_tmp_path = &self.install_path.join(".mod_tmp"); if mod_tmp_path.exists() { @@ -47,17 +47,25 @@ impl ModInstaller { fs::remove_file(self.install_path.join(".mod.zip")) .expect("Could not delete the mod file!"); - let bep_in_ex_dir = mod_tmp_path.join("BepInEx"); - - if bep_in_ex_dir.exists() { - copy_dir_all(bep_in_ex_dir, self.install_path.join("BepInEx")) - .expect("Could not move the BepInEx folder!"); - } else { - copy_dir_all( - mod_tmp_path, - self.install_path.join("BepInEx").join("plugins"), - ) - .expect("Could not move the BepInEx folder!"); + let mod_info = api.get_mod(id).await; + + if let Some(game_id) = mod_info.game_id { + if let Some(game) = KSPGame::from_id(game_id) { + if game.eq(&KSPGame::KSP2) { + let bep_in_ex_dir = mod_tmp_path.join("BepInEx"); + + if bep_in_ex_dir.exists() { + copy_dir_all(bep_in_ex_dir, self.install_path.join("BepInEx")) + .expect("Could not move the BepInEx folder!"); + } else { + copy_dir_all( + mod_tmp_path, + self.install_path.join("BepInEx").join("plugins"), + ) + .expect("Could not move the BepInEx folder!"); + } + } + } } fs::remove_dir_all(mod_tmp_path).expect("Could not delete the mod tmp folder!"); diff --git a/common/src/instances/mod.rs b/common/src/instances/mod.rs index 1c3cffc..3471e51 100644 --- a/common/src/instances/mod.rs +++ b/common/src/instances/mod.rs @@ -14,7 +14,7 @@ pub const KSP1_STEAM_API_SIZE: i32 = 249120; // Information from: SteamDB, DepotDownloader, KSP2 Installed Files pub const KSP2_STEAM_API_SIZE: i32 = 295336; -#[derive(Serialize, Deserialize, Debug, Clone)] +#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] pub enum KSPGame { KSP1 = 3102, KSP2 = 22407, diff --git a/common/src/releases.rs b/common/src/releases.rs index 4c8547b..163ccfc 100644 --- a/common/src/releases.rs +++ b/common/src/releases.rs @@ -33,10 +33,8 @@ pub async fn get_latest_release_zips() -> ReleaseZips { for asset in json.assets { if asset.content_type.eq("application/x-zip-compressed") { // This is so we get only the non-bepinex-packaged version - if !asset.name.to_lowercase().contains("bepinex") { - if zips.bepinex.is_none() { - zips.bepinex = Some(asset.browser_download_url); - } + if !asset.name.to_lowercase().contains("bepinex") && zips.bepinex.is_none() { + zips.bepinex = Some(asset.browser_download_url); } } }