aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri/src')
-rw-r--r--src-tauri/src/northstar/install.rs48
1 files changed, 47 insertions, 1 deletions
diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs
index 693d7af2..a89de018 100644
--- a/src-tauri/src/northstar/install.rs
+++ b/src-tauri/src/northstar/install.rs
@@ -4,7 +4,7 @@ use std::time::Duration;
use std::{cell::RefCell, time::Instant};
use ts_rs::TS;
-use crate::constants::{NORTHSTAR_DEFAULT_PROFILE, NORTHSTAR_DLL, TITANFALL2_STEAM_ID};
+use crate::constants::{CORE_MODS, NORTHSTAR_DEFAULT_PROFILE, NORTHSTAR_DLL, TITANFALL2_STEAM_ID};
use crate::{
util::{extract, move_dir_all},
GameInstall, InstallType,
@@ -162,6 +162,52 @@ async fn do_install(
log::info!("Installing Northstar...");
+ // Delete previous version here
+ for core_mod in CORE_MODS {
+ let path_to_delete_string = format!(
+ "{}/{}/mods/{}/",
+ game_install.game_path, game_install.profile, core_mod
+ );
+ log::info!("Preparing to remove {}", path_to_delete_string);
+
+ // Check if folder exists
+ let path_to_delete = std::path::Path::new(&path_to_delete_string);
+
+ // Check if path even exists before we attempt to remove
+ if !path_to_delete.exists() {
+ log::info!("{} does not exist. Skipping", path_to_delete_string);
+ continue;
+ }
+
+ if !path_to_delete.is_dir() {
+ log::error!(
+ "{} exists but is a file? This should never happen",
+ path_to_delete_string
+ );
+ continue;
+ }
+
+ // Safety check for mod.json
+ // Just so that we won't ever have a https://github.com/ValveSoftware/steam-for-linux/issues/3671 moment
+ let mod_json_path = format!("{}/mod.json", path_to_delete_string);
+ let mod_json_path = std::path::Path::new(&mod_json_path);
+
+ if !mod_json_path.exists() {
+ log::error!("Missing mod.json for {path_to_delete_string} this shouldn't happen");
+ continue;
+ }
+
+ // Finally delete file
+ match std::fs::remove_dir_all(path_to_delete) {
+ Ok(()) => {
+ log::info!("Succesfully removed")
+ }
+ Err(err) => {
+ log::error!("Failed removing {} due to {}", path_to_delete_string, err)
+ }
+ };
+ }
+
for entry in std::fs::read_dir(extract_directory).unwrap() {
let entry = entry.unwrap();
let destination = format!(