diff --git a/src/sync/sync.rs b/src/sync/sync.rs index a47aa5e..0aa5e3a 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -30,32 +30,40 @@ pub async fn run_sync(settings: &Settings) -> Result<(), Box> { let duration = start_time.elapsed(); println!("Finished synchronizing games in: {:?}", duration); if settings.steamgrid_db.enabled { - let auth_key = &settings.steamgrid_db.auth_key; - if let Some(auth_key) = auth_key { - let start_time = std::time::Instant::now(); - println!("Checking for game images"); - let client = steamgriddb_api::Client::new(auth_key); - let mut search = CachedSearch::new(&client); - let known_images = get_users_images(user).unwrap(); - download_images( - known_images, - user.steam_user_data_folder.as_str(), - &shortcut_info.shortcuts, - &mut search, - &client, - ) - .await?; - search.save(); - let duration = start_time.elapsed(); - println!("Finished getting images in: {:?}", duration); - } else { - println!("Steamgrid DB Auth Key not found, please add one as described here: https://github.com/PhilipK/steam_shortcuts_sync#configuration"); - } + find_art(settings, user, &shortcut_info.shortcuts).await?; } } Ok(()) } +async fn find_art( + settings: &Settings, + user: &crate::steam::SteamUsersInfo, + shortcut_info: &Vec, +) -> Result<(), Box> { + let auth_key = &settings.steamgrid_db.auth_key; + Ok(if let Some(auth_key) = auth_key { + let start_time = std::time::Instant::now(); + println!("Checking for game images"); + let client = steamgriddb_api::Client::new(auth_key); + let mut search = CachedSearch::new(&client); + let known_images = get_users_images(user).unwrap(); + download_images( + known_images, + user.steam_user_data_folder.as_str(), + shortcut_info, + &mut search, + &client, + ) + .await?; + search.save(); + let duration = start_time.elapsed(); + println!("Finished getting images in: {:?}", duration); + } else { + println!("Steamgrid DB Auth Key not found, please add one as described here: https://github.com/PhilipK/steam_shortcuts_sync#configuration"); + }) +} + fn update_platforms(settings: &Settings, new_user_shortcuts: &mut Vec) { update_platform_shortcuts( &EpicPlatform::new(settings.epic_games.clone()),