From c834328029846ce0e5785d33e2e854d3cd8557b8 Mon Sep 17 00:00:00 2001 From: Harmony Weblate <96563367+harmony-weblate@users.noreply.github.com> Date: Wed, 19 Jul 2023 17:51:27 +0200 Subject: i18n: Translations update from Weblate (#433) Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (102 of 102 strings) Translation: Northstar/FlightCore Translate-URL: https://translate.harmony.tf/projects/northstar/flightcore/zh_Hans/ Co-authored-by: zxcPandora --- src-vue/src/i18n/lang/zh_Hans.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src-vue/src/i18n/lang/zh_Hans.json b/src-vue/src/i18n/lang/zh_Hans.json index dbc53104..6447a6cf 100644 --- a/src-vue/src/i18n/lang/zh_Hans.json +++ b/src-vue/src/i18n/lang/zh_Hans.json @@ -32,8 +32,8 @@ "servers": "服务器", "players": "玩家", "unable_to_load_playercount": "加载玩家数量失败", - "ea_app_running": "EA App正在运行:", - "northstar_running": "Northstar正在运行:" + "ea_app_running": "EA App运行状态:", + "northstar_running": "Northstar运行状态:" }, "mods": { "local": { -- cgit v1.2.3 From 29837bfe678dad64f01d6f6be69d43d659f402ae Mon Sep 17 00:00:00 2001 From: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> Date: Wed, 19 Jul 2023 23:37:22 +0200 Subject: feat: Add ability to delete package (#425) Adds ability to delete mods from `packages` directory. --- src-tauri/src/mod_management/mod.rs | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs index 2ac26ede..b28671c8 100644 --- a/src-tauri/src/mod_management/mod.rs +++ b/src-tauri/src/mod_management/mod.rs @@ -548,11 +548,58 @@ pub fn delete_northstar_mod(game_install: GameInstall, nsmod_name: String) -> Re Err(format!("Mod {nsmod_name} not found to be installed")) } +/// Deletes a given Thunderstore package +fn delete_package_folder(ts_package_directory: &str) -> Result<(), String> { + let ns_mod_dir_path = std::path::Path::new(&ts_package_directory); + + // Safety check: Check whether `manifest.json` exists and exit early if not + // If it does not exist, we might not be dealing with a Thunderstore package + let mod_json_path = ns_mod_dir_path.join("manifest.json"); + if !mod_json_path.exists() { + // If it doesn't exist, return an error + return Err(format!( + "manifest.json does not exist in {}", + ts_package_directory + )); + } + + match std::fs::remove_dir_all(ts_package_directory) { + Ok(()) => Ok(()), + Err(err) => Err(format!("Failed deleting package: {err}")), + } +} + /// Deletes all NorthstarMods related to a Thunderstore mod #[tauri::command] pub fn delete_thunderstore_mod( game_install: GameInstall, thunderstore_mod_string: String, ) -> Result<(), String> { + // Check packages + let packages_folder = format!("{}/R2Northstar/packages", game_install.game_path); + if std::path::Path::new(&packages_folder).exists() { + for entry in fs::read_dir(packages_folder).unwrap() { + let entry = entry.unwrap(); + + // Check if it's a folder and skip if otherwise + if !entry.file_type().unwrap().is_dir() { + log::warn!("Skipping \"{}\", not a file", entry.path().display()); + continue; + } + + let entry_path = entry.path(); + let package_folder_ts_string = entry_path.file_name().unwrap().to_string_lossy(); + + if package_folder_ts_string != thunderstore_mod_string { + // Not the mod folder we are looking for, try the next one\ + continue; + } + + // All checks passed, this is the matching mod + return delete_package_folder(&entry.path().display().to_string()); + } + } + + // Try legacy mod installs as fallback legacy::delete_thunderstore_mod(game_install, thunderstore_mod_string) } -- cgit v1.2.3