fix: Use deflate-flate2 flag to guard import

This commit is contained in:
Chris Hennick 2024-06-02 17:29:49 -07:00
parent 79fc5a9cdd
commit 2a131e67a9
No known key found for this signature in database
GPG key ID: DA47AABA4961C509
3 changed files with 8 additions and 28 deletions

View file

@ -42,12 +42,12 @@ fn real_main() -> i32 {
let method = match args.compression_method {
CompressionMethod::Stored => zip::CompressionMethod::Stored,
CompressionMethod::Deflated => {
#[cfg(not(feature = "deflate"))]
#[cfg(not(feature = "deflate-flate2"))]
{
println!("The `deflate` feature is not enabled");
println!("The `deflate-flate2` feature is not enabled");
return 1;
}
#[cfg(feature = "deflate")]
#[cfg(feature = "deflate-flate2")]
zip::CompressionMethod::Deflated
}
CompressionMethod::DeflatedZlib => {

View file

@ -24,11 +24,7 @@ use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::{Arc, OnceLock};
#[cfg(any(
feature = "deflate",
feature = "deflate-zlib",
feature = "deflate-zlib-ng"
))]
#[cfg(feature = "deflate-flate2")]
use flate2::read::DeflateDecoder;
#[cfg(feature = "deflate64")]

View file

@ -27,11 +27,7 @@ use std::mem;
use std::str::{from_utf8, Utf8Error};
use std::sync::Arc;
#[cfg(any(
feature = "deflate",
feature = "deflate-zlib",
feature = "deflate-zlib-ng"
))]
#[cfg(feature = "deflate-flate2")]
use flate2::{write::DeflateEncoder, Compression};
#[cfg(feature = "bzip2")]
@ -1569,11 +1565,7 @@ impl<W: Write + Seek> GenericZipWriter<W> {
}
}
#[cfg(any(
feature = "deflate",
feature = "deflate-zlib",
feature = "deflate-zlib-ng",
))]
#[cfg(feature = "deflate-flate2")]
{
Ok(Box::new(move |bare| {
GenericZipWriter::Deflater(DeflateEncoder::new(
@ -1633,11 +1625,7 @@ impl<W: Write + Seek> GenericZipWriter<W> {
fn switch_to(&mut self, make_new_self: SwitchWriterFunction<W>) -> ZipResult<()> {
let bare = match mem::replace(self, Closed) {
Storer(w) => w,
#[cfg(any(
feature = "deflate",
feature = "deflate-zlib",
feature = "deflate-zlib-ng"
))]
#[cfg(feature = "deflate-flate2")]
GenericZipWriter::Deflater(w) => w.finish()?,
#[cfg(feature = "deflate-zopfli")]
GenericZipWriter::ZopfliDeflater(w) => w.finish()?,
@ -1665,11 +1653,7 @@ impl<W: Write + Seek> GenericZipWriter<W> {
fn ref_mut(&mut self) -> Option<&mut dyn Write> {
match self {
Storer(ref mut w) => Some(w as &mut dyn Write),
#[cfg(any(
feature = "deflate",
feature = "deflate-zlib",
feature = "deflate-zlib-ng"
))]
#[cfg(feature = "deflate-flate2")]
GenericZipWriter::Deflater(ref mut w) => Some(w as &mut dyn Write),
#[cfg(feature = "deflate-zopfli")]
GenericZipWriter::ZopfliDeflater(w) => Some(w as &mut dyn Write),