aboutsummaryrefslogtreecommitdiff
path: root/src-tauri
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri')
-rw-r--r--src-tauri/Cargo.lock16
-rw-r--r--src-tauri/Cargo.toml2
-rw-r--r--src-tauri/src/main.rs1
-rw-r--r--src-tauri/src/northstar/profile.rs28
-rw-r--r--src-tauri/src/util.rs1
5 files changed, 38 insertions, 10 deletions
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 89400211..2fdd1077 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -498,9 +498,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
-version = "0.4.31"
+version = "0.4.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38"
+checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb"
dependencies = [
"android-tzdata",
"iana-time-zone",
@@ -508,7 +508,7 @@ dependencies = [
"num-traits",
"serde",
"wasm-bindgen",
- "windows-targets 0.48.1",
+ "windows-targets 0.52.0",
]
[[package]]
@@ -3181,13 +3181,13 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.10.2"
+version = "1.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
+checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"
dependencies = [
"aho-corasick",
"memchr",
- "regex-automata 0.4.3",
+ "regex-automata 0.4.4",
"regex-syntax 0.8.2",
]
@@ -3202,9 +3202,9 @@ dependencies = [
[[package]]
name = "regex-automata"
-version = "0.4.3"
+version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
+checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a"
dependencies = [
"aho-corasick",
"memchr",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 389089b3..7934366b 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -49,7 +49,7 @@ json5 = "0.4.1"
# Async recursion for recursive mod install
async-recursion = "1.0.5"
# For parsing timestamps
-chrono = "0.4.31"
+chrono = "0.4.33"
# TypeScript bindings
ts-rs = "7.1"
# const formatting
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index a2e293b0..1fc55678 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -138,6 +138,7 @@ fn main() {
northstar::install::install_northstar_wrapper,
northstar::install::update_northstar,
northstar::launch_northstar,
+ northstar::profile::clone_profile,
northstar::profile::delete_profile,
northstar::profile::fetch_profiles,
northstar::profile::validate_profile,
diff --git a/src-tauri/src/northstar/profile.rs b/src-tauri/src/northstar/profile.rs
index b0c6c418..26a32d6b 100644
--- a/src-tauri/src/northstar/profile.rs
+++ b/src-tauri/src/northstar/profile.rs
@@ -1,3 +1,4 @@
+use crate::util::copy_dir_all;
use crate::GameInstall;
// These folders are part of Titanfall 2 and
@@ -91,3 +92,30 @@ pub fn delete_profile(game_install: GameInstall, profile: String) -> Result<(),
Err(err) => Err(format!("Failed to delete Profile: {}", err)),
}
}
+
+/// Clones a profile by simply duplicating the folder under a new name
+#[tauri::command]
+pub fn clone_profile(
+ game_install: GameInstall,
+ old_profile: String,
+ new_profile: String,
+) -> Result<(), String> {
+ // Check if the old Profile already exists
+ if !validate_profile(game_install.clone(), old_profile.clone()) {
+ return Err(format!("{} is not a valid Profile", old_profile));
+ }
+
+ // Check that new Profile does not already exist
+ if validate_profile(game_install.clone(), new_profile.clone()) {
+ return Err(format!("{} already exists", new_profile));
+ }
+
+ log::info!("Cloning Profile {} to {}", old_profile, new_profile);
+
+ let old_profile_path = format!("{}/{}", game_install.game_path, old_profile);
+ let new_profile_path = format!("{}/{}", game_install.game_path, new_profile);
+
+ copy_dir_all(old_profile_path, new_profile_path).unwrap();
+
+ Ok(())
+}
diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs
index 15511d21..ad09eec2 100644
--- a/src-tauri/src/util.rs
+++ b/src-tauri/src/util.rs
@@ -188,7 +188,6 @@ pub fn check_northstar_running() -> bool {
}
/// Copies a folder and all its contents to a new location
-#[allow(dead_code)]
pub fn copy_dir_all(
src: impl AsRef<std::path::Path>,
dst: impl AsRef<std::path::Path>,