diff --git a/src/main.rs b/src/main.rs index 32a07be..07a44ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -199,14 +199,20 @@ async fn get_config_from_archive(archive: &mut ZipArchive, out_di } } else if file.name().starts_with(overrides) && file.is_file() { if let Some(path) = file.enclosed_name() { - let realpath = path.parent().unwrap().to_str().unwrap()[overrides.len()..].to_string(); + let realpath = path.parent().unwrap().to_str().unwrap(); + if realpath.len() >= overrides.len() { + let realpath = &realpath[overrides.len()..]; + + // Create directory "out/" + realpath if it doesn't exist + let out_path = out_dir.join(realpath); + tokio::fs::create_dir_all(out_path.clone()).await.ok()?; - // Create directory "out/" + realpath if it doesn't exist - let out_path = out_dir.join(realpath); - tokio::fs::create_dir_all(out_path.clone()).await.ok()?; - - let mut out_file = std::fs::File::create(out_path.join(path.file_name().unwrap())).ok()?; - std::io::copy(&mut file, &mut out_file).expect("Unable to copy file"); + let mut out_file = std::fs::File::create(out_path.join(path.file_name().unwrap())).ok()?; + std::io::copy(&mut file, &mut out_file).expect("Unable to copy file"); + } else { + // Probably just a directory: SKIP + continue; + } } } else { println!("File {} is not a modrinth index file", file.name());