aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/mod_management/legacy.rs
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2023-07-20 01:04:26 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2023-07-20 01:04:26 +0200
commit8ae71ef5f04cab43b19b2b17a26012eeffa62566 (patch)
tree4e7bfc2059904af107f16c107085c27159e06843 /src-tauri/src/mod_management/legacy.rs
parente3c68e1f322b8bbf8b39ecc3b39b46baf59f6ca7 (diff)
downloadFlightCore-8ae71ef5f04cab43b19b2b17a26012eeffa62566.tar.gz
FlightCore-8ae71ef5f04cab43b19b2b17a26012eeffa62566.zip
feat: Delete old version of package on update
also deletes old version of legacy package if installed
Diffstat (limited to 'src-tauri/src/mod_management/legacy.rs')
-rw-r--r--src-tauri/src/mod_management/legacy.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src-tauri/src/mod_management/legacy.rs b/src-tauri/src/mod_management/legacy.rs
index f24f44b6..3136a618 100644
--- a/src-tauri/src/mod_management/legacy.rs
+++ b/src-tauri/src/mod_management/legacy.rs
@@ -115,6 +115,42 @@ pub fn parse_installed_mods(
Ok(mods)
}
+/// Deletes all legacy packages that match in author and mod name
+/// regardless of version
+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,