Skip to content

Commit

Permalink
Fix linting errors (rust)
Browse files Browse the repository at this point in the history
  • Loading branch information
RedstoneWizard08 committed Mar 18, 2023
1 parent 8162d17 commit 8da9dec
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
4 changes: 2 additions & 2 deletions common/src/finder/pdlauncher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
34 changes: 21 additions & 13 deletions common/src/installer/mods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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() {
Expand All @@ -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!");
Expand Down
2 changes: 1 addition & 1 deletion common/src/instances/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions common/src/releases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 8da9dec

Please sign in to comment.