diff --git a/src/main.rs b/src/main.rs index b989bf7..feff509 100644 --- a/src/main.rs +++ b/src/main.rs @@ -367,6 +367,7 @@ struct DownloadHistoryConfig{ } async fn download_history(mut config:DownloadHistoryConfig)->AResult<()>{ + let mut asset_list_contents=std::collections::HashSet::new(); let mut asset_list:Vec=Vec::new(); if config.end_version.is_none()&&config.continue_from_versions{ //load prexisting versions list @@ -380,16 +381,15 @@ async fn download_history(mut config:DownloadHistoryConfig)->AResult<()>{ } } //write down which versions are contained - let mut reference_hashmap=std::collections::HashSet::new(); for asset_version in &asset_list{ - reference_hashmap.insert(asset_version.assetVersionNumber); + asset_list_contents.insert(asset_version.assetVersionNumber); } //find the highest number match asset_list.iter().map(|asset_version|asset_version.assetVersionNumber).max(){ Some(max)=>{ //count down contiguously until a number is missing for i in (1..=max).rev(){ - if !reference_hashmap.contains(&i){ + if !asset_list_contents.contains(&i){ //that is end_version config.end_version=Some(i); break; @@ -402,9 +402,6 @@ async fn download_history(mut config:DownloadHistoryConfig)->AResult<()>{ }, None=>Err(anyhow::Error::msg("Cannot continue from versions.json - there are no previous versions"))?, } - //clear the asset list, I can't tell if roblox provides a way to start on a specific page - //so it just starts from the beginning every time - asset_list.clear(); } let client=reqwest::Client::new(); @@ -422,18 +419,25 @@ async fn download_history(mut config:DownloadHistoryConfig)->AResult<()>{ let asset_id_str=asset_id_string.clone(); let output_folder=config.output_folder.clone(); let data=&page.data; + let asset_list_contents=&asset_list_contents; let join_set=&mut join_set; let error_catcher=||async move{ let mut cancel_paging=false; for asset_version in data{ let version_number=asset_version.assetVersionNumber; + //skip assets beyond specified end_version if config.end_version.is_some_and(|v|vAResult<()>{ }; if page.nextPageCursor.is_none()||cancel_paging{ for asset_version in page.data.into_iter(){ - if config.start_version<=asset_version.assetVersionNumber{ + if !(asset_list_contents.contains(&asset_version.assetVersionNumber) + ||config.end_version.is_some_and(|v|v