mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Do not double import to fix shortcuts (#252)
This commit is contained in:
@@ -101,12 +101,6 @@ pub fn sync_shortcuts(
|
|||||||
|
|
||||||
shortcut_info.shortcuts.extend(all_shortcuts.clone());
|
shortcut_info.shortcuts.extend(all_shortcuts.clone());
|
||||||
|
|
||||||
fix_shortcut_icons(
|
|
||||||
user,
|
|
||||||
&mut shortcut_info.shortcuts,
|
|
||||||
settings.steam.optimize_for_big_picture,
|
|
||||||
);
|
|
||||||
|
|
||||||
save_shortcuts(&shortcut_info.shortcuts, Path::new(&shortcut_info.path));
|
save_shortcuts(&shortcut_info.shortcuts, Path::new(&shortcut_info.path));
|
||||||
|
|
||||||
if settings.steam.create_collections {
|
if settings.steam.create_collections {
|
||||||
@@ -163,11 +157,26 @@ fn remove_old_shortcuts(shortcut_info: &mut ShortcutInfo) {
|
|||||||
.retain(|shortcut| !shortcut.is_boilr_shortcut());
|
.retain(|shortcut| !shortcut.is_boilr_shortcut());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn fix_all_shortcut_icons (
|
||||||
|
settings: &Settings,
|
||||||
|
) -> eyre::Result<()>{
|
||||||
|
let mut userinfo_shortcuts = get_shortcuts_paths(&settings.steam).map_err(|e|eyre::format_err!("Could not find steam shortcuts; {e}"))?;
|
||||||
|
for user in userinfo_shortcuts.iter_mut() {
|
||||||
|
let mut shortcut_info = get_shortcuts_for_user(user);
|
||||||
|
let changes = fix_shortcut_icons(user,&mut shortcut_info.shortcuts,settings.steam.optimize_for_big_picture);
|
||||||
|
if changes{
|
||||||
|
save_shortcuts(&shortcut_info.shortcuts, Path::new(&shortcut_info.path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn fix_shortcut_icons(
|
fn fix_shortcut_icons(
|
||||||
user: &SteamUsersInfo,
|
user: &SteamUsersInfo,
|
||||||
shortcuts: &mut Vec<ShortcutOwned>,
|
shortcuts: &mut Vec<ShortcutOwned>,
|
||||||
big_picture_mode: bool,
|
big_picture_mode: bool,
|
||||||
) {
|
) -> bool {
|
||||||
let image_folder = Path::new(&user.steam_user_data_folder)
|
let image_folder = Path::new(&user.steam_user_data_folder)
|
||||||
.join("config")
|
.join("config")
|
||||||
.join("grid");
|
.join("grid");
|
||||||
@@ -177,17 +186,20 @@ fn fix_shortcut_icons(
|
|||||||
ImageType::Icon
|
ImageType::Icon
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut has_changes = false;
|
||||||
for shortcut in shortcuts {
|
for shortcut in shortcuts {
|
||||||
let app_id = shortcut.app_id;
|
let app_id = shortcut.app_id;
|
||||||
let icon_exsists = Path::new(&shortcut.icon).exists() && !shortcut.icon.is_empty();
|
let icon_exsists = Path::new(&shortcut.icon).exists() && !shortcut.icon.is_empty();
|
||||||
for ext in ["ico", "png", "jpg", "webp"] {
|
for ext in ["ico", "png", "jpg", "webp"] {
|
||||||
let path = image_folder.join(image_type.file_name(app_id, ext));
|
let path = image_folder.join(image_type.file_name(app_id, ext));
|
||||||
if !icon_exsists && path.exists() {
|
if !icon_exsists && path.exists() {
|
||||||
shortcut.icon = format!("\"{}\"", path.to_string_lossy());
|
shortcut.icon = path.to_string_lossy().to_string();
|
||||||
|
has_changes= true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
has_changes
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_shortcut_collections<S: AsRef<str>>(
|
fn write_shortcut_collections<S: AsRef<str>>(
|
||||||
|
|||||||
@@ -152,7 +152,9 @@ impl MyEguiApp {
|
|||||||
let task = download_images(&settings, &usersinfo, &mut some_sender);
|
let task = download_images(&settings, &usersinfo, &mut some_sender);
|
||||||
block_on(task);
|
block_on(task);
|
||||||
//Run a second time to fix up shortcuts after images are downloaded
|
//Run a second time to fix up shortcuts after images are downloaded
|
||||||
sync::sync_shortcuts(&settings, &import_games, &mut some_sender, &renames).unwrap();
|
if let Err(e) = sync::fix_all_shortcut_icons(&settings){
|
||||||
|
eprintln!("Could not fix shortcuts with error {e}");
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(sender) = some_sender {
|
if let Some(sender) = some_sender {
|
||||||
let _ = sender.send(SyncProgress::Done);
|
let _ = sender.send(SyncProgress::Done);
|
||||||
|
|||||||
Reference in New Issue
Block a user