aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/northstar
diff options
context:
space:
mode:
authorJan <sentrycraft123@gmail.com>2023-08-02 12:24:57 +0200
committerGitHub <noreply@github.com>2023-08-02 12:24:57 +0200
commit08d066c7c6c7b99076efb5217474cc5b72df015f (patch)
tree5bb5e2e16c81e6ac01782a6c10d06622dcec8c13 /src-tauri/src/northstar
parentfae4de2fba580e4a1a92b853c479b61e856a3a42 (diff)
downloadFlightCore-08d066c7c6c7b99076efb5217474cc5b72df015f.tar.gz
FlightCore-08d066c7c6c7b99076efb5217474cc5b72df015f.zip
Extract Northstar into temporary location before installing (#456)
This is done in order to enable future changes
Diffstat (limited to 'src-tauri/src/northstar')
-rw-r--r--src-tauri/src/northstar/install.rs44
1 files changed, 31 insertions, 13 deletions
diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs
index eef6c148..80425c56 100644
--- a/src-tauri/src/northstar/install.rs
+++ b/src-tauri/src/northstar/install.rs
@@ -5,7 +5,10 @@ use std::{cell::RefCell, time::Instant};
use ts_rs::TS;
use crate::constants::TITANFALL2_STEAM_ID;
-use crate::{util::extract, GameInstall, InstallType};
+use crate::{
+ util::{extract, move_dir_all},
+ GameInstall, InstallType,
+};
#[cfg(target_os = "windows")]
use crate::platform_specific::windows;
@@ -36,16 +39,13 @@ async fn do_install(
game_install: GameInstall,
) -> Result<()> {
let filename = format!("northstar-{}.zip", nmod.version);
- let download_directory = format!(
- "{}/___flightcore-temp/download-dir/",
- game_install.game_path
- );
-
- log::info!(
- "Attempting to create temporary directory {}",
- download_directory
- );
+ let temp_dir = format!("{}/___flightcore-temp", game_install.game_path);
+ let download_directory = format!("{}/download-dir", temp_dir);
+ let extract_directory = format!("{}/extract-dir", temp_dir);
+
+ log::info!("Attempting to create temporary directory {}", temp_dir);
std::fs::create_dir_all(download_directory.clone())?;
+ std::fs::create_dir_all(extract_directory.clone())?;
let download_path = format!("{}/{}", download_directory, filename);
log::info!("Download path: {download_path}");
@@ -94,11 +94,29 @@ async fn do_install(
.unwrap();
log::info!("Extracting Northstar...");
- extract(nfile, std::path::Path::new(&game_install.game_path))?;
+ extract(nfile, std::path::Path::new(&extract_directory))?;
+
+ log::info!("Installing Northstar...");
+
+ for entry in std::fs::read_dir(extract_directory).unwrap() {
+ let entry = entry.unwrap();
+ let destination = format!(
+ "{}/{}",
+ game_install.game_path,
+ entry.path().file_name().unwrap().to_str().unwrap()
+ );
+
+ log::info!("Installing {}", entry.path().display());
+ if !entry.file_type().unwrap().is_dir() {
+ std::fs::rename(entry.path(), destination)?;
+ } else {
+ move_dir_all(entry.path(), destination)?;
+ }
+ }
// Delete old copy
- log::info!("Delete temp folder again");
- std::fs::remove_dir_all(download_directory).unwrap();
+ log::info!("Delete temporary directory");
+ std::fs::remove_dir_all(temp_dir).unwrap();
log::info!("Done installing Northstar!");
window