From 01c61c71d9ef5f4178831de7600e0d50638554cd Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 31 May 2024 19:00:14 -0700 Subject: [PATCH] set file extension for known file types using fourcc --- src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 054b661..b193527 100644 --- a/src/main.rs +++ b/src/main.rs @@ -205,7 +205,6 @@ async fn main()->AResult<()>{ subcommand.asset_ids.into_iter().map(|asset_id|{ let mut path=output_folder.clone(); path.push(asset_id.to_string()); - path.set_extension("rbxm"); (asset_id,path) }).collect() ).await @@ -342,7 +341,13 @@ async fn download_list(cookie:String,asset_id_file_map:AssetIDFileMap)->AResult< .buffer_unordered(CONCURRENT_REQUESTS) .for_each(|b:AResult<_>|async{ match b{ - Ok((dest,data))=>{ + Ok((mut dest,data))=>{ + //known file types + match &data[0..4]{ + b"dest.set_extension("rbxm"), + b"\x89PNG"=>dest.set_extension("png"), + _=>false, + }; match tokio::fs::write(dest,data).await{ Err(e)=>eprintln!("fs error: {}",e), _=>(),