WIP: Fix upstream merge
This commit is contained in:
parent
b179709639
commit
5bb40012d2
2 changed files with 11 additions and 9 deletions
|
@ -57,7 +57,7 @@ pub(crate) mod zip_archive {
|
||||||
/// for i in 0..zip.len() {
|
/// for i in 0..zip.len() {
|
||||||
/// let mut file = zip.by_index(i)?;
|
/// let mut file = zip.by_index(i)?;
|
||||||
/// println!("Filename: {}", file.name());
|
/// println!("Filename: {}", file.name());
|
||||||
/// std::io::copy(&mut file, &mut std::io::stdout());
|
/// std::io::copy(&mut file, &mut std::io::stdout())?;
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
|
|
18
src/write.rs
18
src/write.rs
|
@ -475,12 +475,8 @@ impl<W: Write + Seek> ZipWriter<W> {
|
||||||
self.stats.hasher = Hasher::new();
|
self.stats.hasher = Hasher::new();
|
||||||
}
|
}
|
||||||
if let Some(keys) = options.encrypt_with {
|
if let Some(keys) = options.encrypt_with {
|
||||||
let mut zipwriter = crate::zipcrypto::ZipCryptoWriter {
|
let mut zipwriter = crate::zipcrypto::ZipCryptoWriter { writer: core::mem::replace(&mut self.inner, GenericZipWriter::Closed).unwrap(), buffer: vec![], keys };
|
||||||
writer: mem::replace(&mut self.inner, Closed).unwrap(),
|
let mut crypto_header = [0u8; 12];
|
||||||
buffer: vec![],
|
|
||||||
keys,
|
|
||||||
};
|
|
||||||
let crypto_header = [0u8; 12];
|
|
||||||
|
|
||||||
zipwriter.write_all(&crypto_header)?;
|
zipwriter.write_all(&crypto_header)?;
|
||||||
self.inner = Storer(MaybeEncrypted::Encrypted(zipwriter));
|
self.inner = Storer(MaybeEncrypted::Encrypted(zipwriter));
|
||||||
|
@ -509,9 +505,15 @@ impl<W: Write + Seek> ZipWriter<W> {
|
||||||
// Implicitly calling [`ZipWriter::end_extra_data`] for empty files.
|
// Implicitly calling [`ZipWriter::end_extra_data`] for empty files.
|
||||||
self.end_extra_data()?;
|
self.end_extra_data()?;
|
||||||
}
|
}
|
||||||
let make_plain_writer = self
|
let make_plain_writer = match self
|
||||||
.inner
|
.inner
|
||||||
.prepare_next_writer(CompressionMethod::Stored, None)?;
|
.prepare_next_writer(CompressionMethod::Stored, None)? {
|
||||||
|
MaybeEncrypted::Encrypted(writer) => {
|
||||||
|
let crc32 = self.stats.hasher.clone().finalize();
|
||||||
|
self.inner = Storer(MaybeEncrypted::Unencrypted(writer.finish(crc32)?))
|
||||||
|
},
|
||||||
|
MaybeEncrypted::Unencrypted(writer) => writer
|
||||||
|
}
|
||||||
self.inner.switch_to(make_plain_writer)?;
|
self.inner.switch_to(make_plain_writer)?;
|
||||||
let writer = self.inner.get_plain();
|
let writer = self.inner.get_plain();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue