From de7b0bd5cc38b169b38b2d15b774510bec093bce Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 29 Sep 2023 03:14:29 -0700 Subject: [PATCH] stop failing when maps are corrupted while downloading textures --- src/main.rs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index aef4c3f..92940bc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -261,21 +261,23 @@ fn download_textures(paths: Vec) -> BoxResult<()>{ ]; let mut texture_list=std::collections::HashSet::new(); for path in paths { - let input = std::io::BufReader::new(std::fs::File::open(path)?); + let input = std::io::BufReader::new(std::fs::File::open(path.clone())?); - let dom = rbx_binary::from_reader(input)?; - - let object_refs = get_texture_refs(&dom); - - for &object_ref in object_refs.iter() { - if let Some(object)=dom.get_by_ref(object_ref){ - if let Some(rbx_dom_weak::types::Variant::Content(content)) = object.properties.get("Texture") { - println!("Texture content:{:?}",content); - if let Ok(asset_id)=content.clone().into_string().parse::(){ - texture_list.insert(asset_id.0); + match rbx_binary::from_reader(input){ + Ok(dom)=>{ + let object_refs = get_texture_refs(&dom); + for &object_ref in object_refs.iter() { + if let Some(object)=dom.get_by_ref(object_ref){ + if let Some(rbx_dom_weak::types::Variant::Content(content)) = object.properties.get("Texture") { + println!("Texture content:{:?}",content); + if let Ok(asset_id)=content.clone().into_string().parse::(){ + texture_list.insert(asset_id.0); + } + } } } - } + }, + Err(e)=>println!("error loading map {:?}: {:?}",path.file_name(),e), } } println!("Texture list:{:?}",texture_list);