Correct logging when no need for download

This commit is contained in:
Philip Kristoffersen
2021-10-07 13:18:21 +02:00
parent fd13ce6fb5
commit 978eaaa1e2
2 changed files with 24 additions and 19 deletions
+3 -1
View File
@@ -164,11 +164,13 @@ impl Error for SteamUsersDataEmpty {
} }
pub fn get_users_images(user: &SteamUsersInfo) -> Result<Vec<String>, Box<dyn Error>> { pub fn get_users_images(user: &SteamUsersInfo) -> Result<Vec<String>, Box<dyn Error>> {
let grid_folder = Path::new(user.steam_user_data_folder.as_str()).join("config/grid"); let grid_folder = Path::new(user.steam_user_data_folder.as_str()).join("config/grid");
if !grid_folder.exists() {
std::fs::create_dir_all(&grid_folder)?; std::fs::create_dir_all(&grid_folder)?;
}
let user_folders = std::fs::read_dir(&grid_folder)?; let user_folders = std::fs::read_dir(&grid_folder)?;
let file_names = user_folders let file_names = user_folders
.filter_map(|image| image.ok()) .filter_map(|image| image.ok())
.map(|image| image.file_name().into_string().unwrap()) .map(|image| image.file_name().to_string_lossy().to_string())
.collect(); .collect();
Ok(file_names) Ok(file_names)
} }
+7 -4
View File
@@ -18,11 +18,10 @@ use super::CachedSearch;
const CONCURRENT_REQUESTS: usize = 10; const CONCURRENT_REQUESTS: usize = 10;
pub async fn download_images_for_users<'b>(settings: &Settings, users: &Vec<SteamUsersInfo>) { pub async fn download_images_for_users<'b>(settings: &Settings, users: &Vec<SteamUsersInfo>) {
let start_time = std::time::Instant::now();
let auth_key = &settings.steamgrid_db.auth_key; let auth_key = &settings.steamgrid_db.auth_key;
if let Some(auth_key) = auth_key { if let Some(auth_key) = auth_key {
println!("Checking for game images"); println!("Checking for game images");
let start_time = std::time::Instant::now();
let client = steamgriddb_api::Client::new(auth_key); let client = steamgriddb_api::Client::new(auth_key);
let search = CachedSearch::new(&client); let search = CachedSearch::new(&client);
let search = &search; let search = &search;
@@ -47,6 +46,7 @@ pub async fn download_images_for_users<'b>(settings: &Settings, users: &Vec<Stea
.collect::<Vec<Vec<ToDownload>>>() .collect::<Vec<Vec<ToDownload>>>()
.await; .await;
let to_downloads = to_downloads.iter().flatten().collect::<Vec<&ToDownload>>(); let to_downloads = to_downloads.iter().flatten().collect::<Vec<&ToDownload>>();
if !to_downloads.is_empty() {
search.save(); search.save();
stream::iter(to_downloads) stream::iter(to_downloads)
@@ -59,8 +59,10 @@ pub async fn download_images_for_users<'b>(settings: &Settings, users: &Vec<Stea
.collect::<Vec<()>>() .collect::<Vec<()>>()
.await; .await;
let duration = start_time.elapsed(); let duration = start_time.elapsed();
println!("Finished getting images in: {:?}", duration); println!("Finished getting images in: {:?}", duration);
} else {
println!("No images needed");
}
} else { } else {
println!("Steamgrid DB Auth Key not found, please add one as described here: https://github.com/PhilipK/steam_shortcuts_sync#configuration"); println!("Steamgrid DB Auth Key not found, please add one as described here: https://github.com/PhilipK/steam_shortcuts_sync#configuration");
} }
@@ -82,7 +84,8 @@ async fn search_fo_to_download<'b>(
// if we are missing any of the images we need to search for them // if we are missing any of the images we need to search for them
images.iter().any(|image| !known_images.contains(&image)) && "" != s.app_name images.iter().any(|image| !known_images.contains(&image)) && "" != s.app_name
}); });
if shortcuts_to_search_for.clone().count() == 0 { let shortcuts_to_search_for: Vec<&ShortcutOwned> = shortcuts_to_search_for.collect();
if shortcuts_to_search_for.is_empty() {
return Ok(vec![]); return Ok(vec![]);
} }
let mut search_results = HashMap::new(); let mut search_results = HashMap::new();