diff --git a/Cargo.lock b/Cargo.lock index 4dc660d..b5fe2d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -629,7 +629,9 @@ dependencies = [ [[package]] name = "rawzip" -version = "0.2.0" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e512201a808c46ad2a0c810057db306d66b58d5516304548d2445a53db933499" [[package]] name = "rcgen" diff --git a/Cargo.toml b/Cargo.toml index 4fa411e..cb80b7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,14 +24,11 @@ webpki = "0.22.4" ring = "0.17.14" tokio = { version = "1.45.1", features = ["fs", "io-util"] } tokio-util = { version = "0.7.15", features = ["codec"] } -rawzip = "0.2.0" +rawzip = "0.3.0" [package.metadata.patch] crates = ["rawzip"] -[patch.crates-io] -rawzip = { path="./target/patch/rawzip-0.2.0" } - [dependencies.x509-parser] version = "0.17.0" features = ["verify"] diff --git a/patches/rawzip+0.2.0.patch b/patches/rawzip+0.2.0.patch deleted file mode 100644 index e0cb06a..0000000 --- a/patches/rawzip+0.2.0.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/src/archive.rs b/src/archive.rs -index 1203015..837c405 100644 ---- a/src/archive.rs -+++ b/src/archive.rs -@@ -275,7 +275,7 @@ impl<'data> Iterator for ZipSliceEntries<'data> { - /// ``` - #[derive(Debug, Clone)] - pub struct ZipArchive { -- pub(crate) reader: R, -+ pub reader: R, - pub(crate) comment: ZipString, - pub(crate) eocd: EndOfCentralDirectory, - } -@@ -431,9 +431,9 @@ where - #[derive(Debug, Clone)] - pub struct ZipEntry<'archive, R> { - archive: &'archive ZipArchive, -- body_offset: u64, -- body_end_offset: u64, -- entry: ZipArchiveEntryWayfinder, -+ pub body_offset: u64, -+ pub body_end_offset: u64, -+ pub entry: ZipArchiveEntryWayfinder, - } - - impl<'archive, R> ZipEntry<'archive, R> diff --git a/src/version/backends.rs b/src/version/backends.rs index 69008c1..ec486d0 100644 --- a/src/version/backends.rs +++ b/src/version/backends.rs @@ -75,12 +75,17 @@ impl ZipVersionBackend { } } - pub fn new_entry(&self, entry: ZipEntry<'_, FileReader>) -> ZipFileWrapper { + pub fn new_entry( + &self, + entry: ZipEntry<'_, FileReader>, + wayfinder: ZipArchiveEntryWayfinder, + ) -> ZipFileWrapper { + let (offset, end_offset) = entry.compressed_data_range(); ZipFileWrapper { archive: self.archive.clone(), - wayfinder: entry.entry, - offset: entry.body_offset, - end_offset: entry.body_end_offset, + wayfinder, + offset, + end_offset, } } } @@ -97,7 +102,7 @@ impl Read for ZipFileWrapper { let read_size = buf.len().min((self.end_offset - self.offset) as usize); let read = self .archive - .reader + .get_ref() .read_at(&mut buf[..read_size], self.offset)?; self.offset += read as u64; Ok(read) @@ -120,8 +125,8 @@ impl VersionBackend for ZipVersionBackend { continue; } results.push(VersionFile { - relative_filename: entry.file_safe_path().unwrap().to_string(), - permission: 744, // apparently ZIPs with permissions are not supported by this library, so we let the owner do anything + relative_filename: String::from(entry.file_path().try_normalize().unwrap()), + permission: entry.mode().permissions(), size: entry.uncompressed_size_hint(), }); } @@ -133,7 +138,7 @@ impl VersionBackend for ZipVersionBackend { let mut entries = self.archive.entries(read_buffer); let entry = loop { if let Some(v) = entries.next_entry().unwrap() { - if v.file_safe_path().unwrap().to_string() == file.relative_filename { + if v.file_path().try_normalize().unwrap().as_ref() == &file.relative_filename { break Some(v); } } else { @@ -144,7 +149,7 @@ impl VersionBackend for ZipVersionBackend { let wayfinder = entry.wayfinder(); let local_entry = self.archive.get_entry(wayfinder).unwrap(); - let wrapper = self.new_entry(local_entry); + let wrapper = self.new_entry(local_entry, wayfinder); Some(Box::new(wrapper)) }