From 3663cbb84970c17445b2ce0f7a162c0b319a92a8 Mon Sep 17 00:00:00 2001 From: Philip Kristoffersen Date: Mon, 21 Mar 2022 13:57:01 +0100 Subject: [PATCH] Fix non boilr shortcuts getting deleted --- src/sync/synchronization.rs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/sync/synchronization.rs b/src/sync/synchronization.rs index 3f6e4a5..8a05769 100644 --- a/src/sync/synchronization.rs +++ b/src/sync/synchronization.rs @@ -33,7 +33,6 @@ pub async fn run_sync(settings: &Settings) -> Result<(), Box> { remove_old_shortcuts(&mut shortcut_info); update_platforms(settings, &mut shortcut_info.shortcuts); fix_shortcut_icons(user, &mut shortcut_info.shortcuts); - set_dev_kit_game_id_to_boilr( &mut shortcut_info); save_shortcuts(&shortcut_info.shortcuts, Path::new(&shortcut_info.path)); user.shortcut_path = Some(shortcut_info.path.to_string_lossy().to_string()); @@ -52,13 +51,6 @@ pub async fn run_sync(settings: &Settings) -> Result<(), Box> { Ok(()) } - -fn set_dev_kit_game_id_to_boilr(shortcut_info: &mut ShortcutInfo){ - shortcut_info.shortcuts.iter_mut().for_each(|shortcut|{ - shortcut.dev_kit_game_id = format!("{}{}", BOILR_TAG,shortcut.app_id); - }) -} - fn remove_old_shortcuts(shortcut_info: &mut ShortcutInfo) { let boilr_tag = BOILR_TAG.to_string(); shortcut_info @@ -188,22 +180,26 @@ where } let shortcuts_to_add_result = platform.get_shortcuts(); + match shortcuts_to_add_result { Ok(shortcuts_to_add) => { + let mut shortcuts_to_add_transformed = vec![]; + for shortcut in shortcuts_to_add{ + let mut shortcut_owned: ShortcutOwned = shortcut.into(); + shortcut_owned.dev_kit_game_id = format!("{}-{}",BOILR_TAG,shortcut_owned.app_id); + shortcuts_to_add_transformed.push(shortcut_owned); + } + + let shortcuts_to_add = shortcuts_to_add_transformed; + println!( "Found {} game(s) for platform {}", shortcuts_to_add.len(), platform.name() ); - current_shortcuts.retain(|f| !f.tags.contains(&platform.name().to_owned())); - let boilr_tag = BOILR_TAG.to_string(); - for shortcut in shortcuts_to_add { - let mut shortcut_owned: ShortcutOwned = shortcut.into(); - if !shortcut_owned.tags.contains(&boilr_tag) { - shortcut_owned.tags.push(boilr_tag.clone()); - } + for shortcut_owned in shortcuts_to_add { #[cfg(target_family = "unix")] let shortcut_owned = if platform.create_symlinks() { crate::sync::symlinks::create_sym_links(&shortcut_owned)