aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/mod_management/legacy.rs
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-07-21 12:43:11 +0200
committerGitHub <noreply@github.com>2023-07-21 12:43:11 +0200
commit672ee8e0df804caa4c746dbc9ce7efc5c3674647 (patch)
tree6f83846289f0d8653237e8f3584f4cfdef80395c /src-tauri/src/mod_management/legacy.rs
parent99920002511676f55b8a45e51b5c735f50db4bd6 (diff)
downloadFlightCore-672ee8e0df804caa4c746dbc9ce7efc5c3674647.tar.gz
FlightCore-672ee8e0df804caa4c746dbc9ce7efc5c3674647.zip
feat: Support installing Thunderstore packages (#426)
Support for installing mods from Thunderstore directly into the `packages` folder. Adds some basic sanity check during installation. After successful installation, the old version of the mod is removed. This includes both from `packages` and from `mods`.
Diffstat (limited to 'src-tauri/src/mod_management/legacy.rs')
-rw-r--r--src-tauri/src/mod_management/legacy.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src-tauri/src/mod_management/legacy.rs b/src-tauri/src/mod_management/legacy.rs
index f24f44b6..91463250 100644
--- a/src-tauri/src/mod_management/legacy.rs
+++ b/src-tauri/src/mod_management/legacy.rs
@@ -115,6 +115,46 @@ pub fn parse_installed_mods(
Ok(mods)
}
+/// Deletes all legacy packages that match in author and mod name
+/// regardless of version
+///
+/// "legacy package" refers to a Thunderstore package installed into the `mods` folder
+/// by extracting Northstar mods contained inside and then adding `manifest.json` and `thunderstore_author.txt`
+/// to indicate which Thunderstore package they are part of
+pub fn delete_legacy_package_install(
+ thunderstore_mod_string: &str,
+ game_install: &GameInstall,
+) -> Result<(), String> {
+ let thunderstore_mod_string: ParsedThunderstoreModString =
+ thunderstore_mod_string.parse().unwrap();
+ let found_installed_legacy_mods = match parse_installed_mods(game_install) {
+ Ok(res) => res,
+ Err(err) => return Err(err.to_string()),
+ };
+
+ for legacy_mod in found_installed_legacy_mods {
+ if legacy_mod.thunderstore_mod_string.is_none() {
+ continue; // Not a thunderstore mod
+ }
+
+ let current_mod_ts_string: ParsedThunderstoreModString = legacy_mod
+ .clone()
+ .thunderstore_mod_string
+ .unwrap()
+ .parse()
+ .unwrap();
+
+ if thunderstore_mod_string.author_name == current_mod_ts_string.author_name
+ && thunderstore_mod_string.mod_name == current_mod_ts_string.mod_name
+ {
+ // They match, delete
+ delete_mod_folder(&legacy_mod.directory)?;
+ }
+ }
+
+ Ok(())
+}
+
/// Deletes all NorthstarMods related to a Thunderstore mod
pub fn delete_thunderstore_mod(
game_install: GameInstall,