Ignore directory definitions in overrides

This commit is contained in:
Gabriel Tofvesson 2025-05-19 01:46:53 +02:00
parent bd13ce1fb2
commit 2bcdb8c428

View File

@ -199,14 +199,20 @@ async fn get_config_from_archive(archive: &mut ZipArchive<std::fs::File>, 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());