From 1b3a8be1426e3df67c5a004bb8c829c6f7d7cd0c Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 12 Jan 2024 16:27:31 -0800 Subject: [PATCH] start version argument --- src/main.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 691fb5e..0a557ad 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,6 +25,8 @@ struct Cli{ cookie_env:Option, #[arg(long)] cookie_file:Option, + #[arg(long)] + start_version:Option, //decompile options #[arg(long)] @@ -134,6 +136,7 @@ async fn main()->AResult<()>{ match cli.command{ Commands::DownloadHistory=>download_history(DownloadHistoryConfig{ + start_version:cli.start_version.unwrap_or(0), output_folder:cli.output.unwrap(), cookie:cookie.unwrap(), asset_id:cli.asset_id.unwrap(), @@ -348,6 +351,7 @@ async fn download_asset_version(client:&reqwest::Client,cookie:&str,asset_id_str } struct DownloadHistoryConfig{ + start_version:u64, output_folder:std::path::PathBuf, cookie:String, asset_id:AssetID, @@ -364,8 +368,13 @@ async fn download_history(config:DownloadHistoryConfig)->AResult<()>{ let mut join_handles=Vec::new(); loop{ let mut page=download_page(&client,config.cookie.as_str(),config.asset_id,cursor).await?; + let mut cancel_paging=false; for asset_version in &page.data{ let version_number=asset_version.assetVersionNumber; + if version_numberAResult<()>{ Ok::<_,anyhow::Error>(()) })); } - asset_list.append(&mut page.data); - if page.nextPageCursor.is_none(){ + if page.nextPageCursor.is_none()||cancel_paging{ + for asset_version in page.data.into_iter(){ + if config.start_version<=asset_version.assetVersionNumber{ + asset_list.push(asset_version); + } + } break; + }else{ + asset_list.append(&mut page.data); } cursor=page.nextPageCursor; }