From 4ffce253f2f73c4d796346291d27f311ccb1f5ea Mon Sep 17 00:00:00 2001 From: Skywalkingzulu1 Date: Thu, 15 Oct 2026 18:42:33 +0200 Subject: [PATCH] fix(io): adapt to zip 9 API - last_modified_time takes DateTime directly, drop the Some() wrapper - file_names() returns Result, ZipError>: propagate errors, compare the Cow, and push the resolved name into seen - test helper: ZipFile::name() now returns Result, unwrap it - update the Cargo.toml comment explaining why we moved ahead of SolidCraft (still on zip 3) - update Cargo.lock to zip 9.0.3 --- crates/io/src/lib.rs | 5 +++-- crates/io/tests/file.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/io/src/lib.rs b/crates/io/src/lib.rs index 044bb94..753b755 100644 --- a/crates/io/src/lib.rs +++ b/crates/io/src/lib.rs @@ -335,7 +335,7 @@ pub fn write(model: &Model, geometry: &Geometry, journal: &[JournalEntry], view: // Fixed time and permissions: the bytes depend on the model only. let options = zip::write::SimpleFileOptions::default() .compression_method(zip::CompressionMethod::Stored) - .last_modified_time(Some(zip::DateTime::default())) + .last_modified_time(zip::DateTime::default()) .unix_permissions(0o644) .large_file(bytes.len() as u64 >= u64::from(u32::MAX)); zip.start_file(name, options).map_err(zip_error)?; @@ -372,7 +372,8 @@ pub fn read(bytes: &[u8]) -> Result { let names = [MANIFEST, MODEL, MESH, JOURNAL]; let mut seen = Vec::with_capacity(zip.len()); for name in zip.file_names() { - if !names.contains(&name) { + let name = name.map_err(|e| Error::Invalid(format!("not a FieldCraft file: {e}")))?; + if !names.contains(&name.as_ref()) { return invalid(format!("unexpected part `{}`", name.chars().take(80).collect::())); } if seen.contains(&name) { diff --git a/crates/io/tests/file.rs b/crates/io/tests/file.rs index e1e137d..03c8e2c 100644 --- a/crates/io/tests/file.rs +++ b/crates/io/tests/file.rs @@ -52,7 +52,7 @@ fn parts(bytes: &[u8]) -> Vec<(String, Vec)> { let mut f = zip.by_index(i).unwrap(); let mut b = Vec::new(); f.read_to_end(&mut b).unwrap(); - (f.name().to_string(), b) + (f.name().unwrap().to_string(), b) }) .collect() }