fix(io): adapt to zip 9 API

- last_modified_time takes DateTime directly, drop the Some() wrapper
- file_names() returns Result<Cow<str>, ZipError>: propagate errors, compare
  the Cow<str>, 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
This commit is contained in:
Skywalkingzulu1 authored and Irakli Kourtis committed 2026-10-15 15:08:13 -04:00
1 parent 8e28283dad
commit 4ffce253f2
2 files changed
+4 -3

No files matched your search

+3 -2
View File
@@ -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<ModelFile> {
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::<String>()));
}
if seen.contains(&name) {
+1 -1
View File
@@ -52,7 +52,7 @@ fn parts(bytes: &[u8]) -> Vec<(String, Vec<u8>)> {
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()
}