remove deflate feature; make it a hard dependency
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>pull/298/head
parent
a337e2269e
commit
b4f2f33576
|
@ -25,7 +25,7 @@ bitflags = { version = "2.4", features = ["serde"] }
|
|||
data-encoding = { version = "2.1.1" }
|
||||
encoding = { version = "0.2.33", default-features = false }
|
||||
encoding_rs = { version = "^0.8" }
|
||||
flate2 = { version = "1.0.16", optional = true }
|
||||
flate2 = { version = "1.0.16" }
|
||||
futures = "0.3.5"
|
||||
|
||||
imap-codec = { version = "1.0.0", features = ["ext_condstore_qresync"], optional = true }
|
||||
|
@ -60,11 +60,13 @@ xdg-utils = "^0.4.0"
|
|||
mailin-embedded = { version = "0.7", features = ["rtls"] }
|
||||
stderrlog = "^0.5"
|
||||
|
||||
[build-dependencies]
|
||||
flate2 = { version = "1.0.16" }
|
||||
|
||||
[features]
|
||||
default = ["unicode_algorithms", "imap", "nntp", "maildir", "mbox", "vcard", "smtp", "deflate_compression"]
|
||||
default = ["unicode-algorithms", "imap", "nntp", "maildir", "mbox", "vcard", "smtp"]
|
||||
|
||||
debug-tracing = []
|
||||
deflate_compression = ["flate2"]
|
||||
gpgme = []
|
||||
http = ["isahc"]
|
||||
http-static = ["isahc", "isahc/static-curl"]
|
||||
|
@ -81,5 +83,7 @@ smtp = ["tls", "base64"]
|
|||
smtp-trace = ["smtp"]
|
||||
sqlite3 = ["rusqlite", ]
|
||||
tls = ["native-tls"]
|
||||
unicode_algorithms = ["unicode-segmentation"]
|
||||
text-processing = []
|
||||
unicode-algorithms = ["text-processing", "unicode-segmentation"]
|
||||
unicode-algorithms-cached = ["text-processing", "unicode-segmentation"]
|
||||
vcard = []
|
||||
|
|
|
@ -9,7 +9,6 @@ Library for handling mail.
|
|||
| feature flag | dependencies | notes |
|
||||
| ---------------------- | ----------------------------------- | ------------------------ |
|
||||
| `imap` | `native-tls` | |
|
||||
| `deflate_compression` | `flate2` | for use with IMAP |
|
||||
| `jmap` | `isahc`, `native-tls`, `serde_json` | |
|
||||
| `maildir` | `notify` | |
|
||||
| `mbox` | `notify` | |
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
|
||||
#![allow(clippy::needless_range_loop)]
|
||||
|
||||
#[cfg(feature = "unicode_algorithms")]
|
||||
#[cfg(any(feature = "unicode-algorithms", feature = "unicode-algorithms-cached"))]
|
||||
include!("src/text_processing/types.rs");
|
||||
|
||||
fn main() -> Result<(), std::io::Error> {
|
||||
#[cfg(feature = "unicode_algorithms")]
|
||||
#[cfg(any(feature = "unicode-algorithms", feature = "unicode-algorithms-cached"))]
|
||||
{
|
||||
const MOD_PATH: &str = "src/text_processing/tables.rs";
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
@ -52,7 +52,25 @@ fn main() -> Result<(), std::io::Error> {
|
|||
"{} already exists, delete it if you want to replace it.",
|
||||
mod_path.display()
|
||||
);
|
||||
std::process::exit(0);
|
||||
return Ok(());
|
||||
}
|
||||
if cfg!(feature = "unicode-algorithms-cached") {
|
||||
const CACHED_MODULE: &[u8] =
|
||||
include_bytes!(concat!("./src/text_processing/tables.rs.gz"));
|
||||
|
||||
let mut gz = GzDecoder::new(CACHED_MODULE);
|
||||
use flate2::bufread::GzDecoder;
|
||||
let mut v = String::with_capacity(
|
||||
8, /*
|
||||
str::parse::<usize>(unsafe {
|
||||
std::str::from_utf8_unchecked(gz.header().unwrap().comment().unwrap())
|
||||
})
|
||||
.unwrap_or_else(|_| panic!("was not compressed with size comment header",)),*/
|
||||
);
|
||||
gz.read_to_string(&mut v)?;
|
||||
let mut file = File::create(mod_path)?;
|
||||
file.write_all(v.as_bytes())?;
|
||||
return Ok(());
|
||||
}
|
||||
let mut child = Command::new("curl")
|
||||
.args(["-o", "-", LINE_BREAK_TABLE_URL])
|
||||
|
|
|
@ -44,15 +44,13 @@ use std::{
|
|||
};
|
||||
|
||||
use futures::io::{AsyncReadExt, AsyncWriteExt};
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
use imap_codec::imap_types::extensions::compress::CompressionAlgorithm;
|
||||
use imap_codec::{
|
||||
encode::{Encoder, Fragment},
|
||||
imap_types::{
|
||||
auth::AuthMechanism,
|
||||
command::{Command, CommandBody},
|
||||
core::{AString, LiteralMode, NonEmptyVec, Tag},
|
||||
extensions::enable::CapabilityEnable,
|
||||
extensions::{compress::CompressionAlgorithm, enable::CapabilityEnable},
|
||||
mailbox::Mailbox,
|
||||
search::SearchKey,
|
||||
secret::Secret,
|
||||
|
@ -100,7 +98,6 @@ pub enum ImapProtocol {
|
|||
pub struct ImapExtensionUse {
|
||||
pub condstore: bool,
|
||||
pub idle: bool,
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
pub deflate: bool,
|
||||
pub oauth2: bool,
|
||||
}
|
||||
|
@ -110,7 +107,6 @@ impl Default for ImapExtensionUse {
|
|||
Self {
|
||||
condstore: true,
|
||||
idle: true,
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
deflate: true,
|
||||
oauth2: false,
|
||||
}
|
||||
|
@ -694,7 +690,6 @@ impl ImapConnection {
|
|||
extension_use:
|
||||
ImapExtensionUse {
|
||||
condstore,
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
deflate,
|
||||
idle: _idle,
|
||||
oauth2: _,
|
||||
|
@ -735,7 +730,6 @@ impl ImapConnection {
|
|||
}
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
if capabilities.contains(&b"COMPRESS=DEFLATE"[..]) && deflate {
|
||||
let mut ret = Vec::new();
|
||||
self.send_command(CommandBody::compress(CompressionAlgorithm::Deflate))
|
||||
|
|
|
@ -79,7 +79,6 @@ pub type MessageSequenceNumber = ImapNum;
|
|||
|
||||
pub static SUPPORTED_CAPABILITIES: &[&str] = &[
|
||||
"AUTH=OAUTH2",
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
"COMPRESS=DEFLATE",
|
||||
"CONDSTORE",
|
||||
"ENABLE",
|
||||
|
@ -230,7 +229,6 @@ impl MailBackend for ImapType {
|
|||
extension_use:
|
||||
ImapExtensionUse {
|
||||
idle,
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
deflate,
|
||||
condstore,
|
||||
oauth2,
|
||||
|
@ -249,20 +247,11 @@ impl MailBackend for ImapType {
|
|||
}
|
||||
}
|
||||
"COMPRESS=DEFLATE" => {
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
{
|
||||
if deflate {
|
||||
*status = MailBackendExtensionStatus::Enabled { comment: None };
|
||||
} else {
|
||||
*status = MailBackendExtensionStatus::Supported {
|
||||
comment: Some("Disabled by user configuration"),
|
||||
};
|
||||
}
|
||||
}
|
||||
#[cfg(not(feature = "deflate_compression"))]
|
||||
{
|
||||
*status = MailBackendExtensionStatus::Unsupported {
|
||||
comment: Some("melib not compiled with DEFLATE."),
|
||||
if deflate {
|
||||
*status = MailBackendExtensionStatus::Enabled { comment: None };
|
||||
} else {
|
||||
*status = MailBackendExtensionStatus::Supported {
|
||||
comment: Some("Disabled by user configuration"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1296,7 +1285,6 @@ impl ImapType {
|
|||
extension_use: ImapExtensionUse {
|
||||
idle: get_conf_val!(s["use_idle"], true)?,
|
||||
condstore: get_conf_val!(s["use_condstore"], true)?,
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
deflate: get_conf_val!(s["use_deflate"], true)?,
|
||||
oauth2: use_oauth2,
|
||||
},
|
||||
|
@ -1566,16 +1554,7 @@ impl ImapType {
|
|||
}
|
||||
get_conf_val!(s["use_idle"], true)?;
|
||||
get_conf_val!(s["use_condstore"], true)?;
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
get_conf_val!(s["use_deflate"], true)?;
|
||||
#[cfg(not(feature = "deflate_compression"))]
|
||||
if s.extra.contains_key("use_deflate") {
|
||||
return Err(Error::new(format!(
|
||||
"Configuration error ({}): setting `use_deflate` is set but this version of meli \
|
||||
isn't compiled with DEFLATE support.",
|
||||
s.name.as_str(),
|
||||
)));
|
||||
}
|
||||
let _timeout = get_conf_val!(s["timeout"], 16_u64)?;
|
||||
let extra_keys = s
|
||||
.extra
|
||||
|
|
|
@ -128,7 +128,7 @@ pub mod dbg {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "unicode_algorithms")]
|
||||
#[cfg(feature = "text-processing")]
|
||||
pub mod text_processing;
|
||||
|
||||
pub use utils::{
|
||||
|
|
|
@ -37,7 +37,6 @@ use super::{Capabilities, NntpServerConf, UIDStore};
|
|||
|
||||
#[derive(Debug, Default, Clone, Copy)]
|
||||
pub struct NntpExtensionUse {
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
pub deflate: bool,
|
||||
}
|
||||
|
||||
|
@ -258,7 +257,6 @@ impl NntpStream {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
if capabilities.contains("COMPRESS DEFLATE") && ret.extension_use.deflate {
|
||||
ret.send_command(b"COMPRESS DEFLATE").await?;
|
||||
ret.read_response(&mut res, false, command_to_replycodes("COMPRESS DEFLATE"))
|
||||
|
|
|
@ -91,7 +91,6 @@ macro_rules! get_conf_val {
|
|||
}
|
||||
|
||||
pub static SUPPORTED_CAPABILITIES: &[&str] = &[
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
"COMPRESS DEFLATE",
|
||||
"VERSION 2",
|
||||
"NEWNEWS",
|
||||
|
@ -185,10 +184,7 @@ impl MailBackend for NntpType {
|
|||
})
|
||||
.collect::<Vec<(String, MailBackendExtensionStatus)>>();
|
||||
let mut supports_submission = false;
|
||||
let NntpExtensionUse {
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
deflate,
|
||||
} = self.server_conf.extension_use;
|
||||
let NntpExtensionUse { deflate } = self.server_conf.extension_use;
|
||||
{
|
||||
for (name, status) in extensions.iter_mut() {
|
||||
match name.as_str() {
|
||||
|
@ -197,20 +193,11 @@ impl MailBackend for NntpType {
|
|||
*status = MailBackendExtensionStatus::Enabled { comment: None };
|
||||
}
|
||||
"COMPRESS DEFLATE" => {
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
{
|
||||
if deflate {
|
||||
*status = MailBackendExtensionStatus::Enabled { comment: None };
|
||||
} else {
|
||||
*status = MailBackendExtensionStatus::Supported {
|
||||
comment: Some("Disabled by user configuration"),
|
||||
};
|
||||
}
|
||||
}
|
||||
#[cfg(not(feature = "deflate_compression"))]
|
||||
{
|
||||
*status = MailBackendExtensionStatus::Unsupported {
|
||||
comment: Some("melib not compiled with DEFLATE."),
|
||||
if deflate {
|
||||
*status = MailBackendExtensionStatus::Enabled { comment: None };
|
||||
} else {
|
||||
*status = MailBackendExtensionStatus::Supported {
|
||||
comment: Some("Disabled by user configuration"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -680,7 +667,6 @@ impl NntpType {
|
|||
use_starttls,
|
||||
danger_accept_invalid_certs,
|
||||
extension_use: NntpExtensionUse {
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
deflate: get_conf_val!(s["use_deflate"], false)?,
|
||||
},
|
||||
};
|
||||
|
@ -859,16 +845,7 @@ impl NntpType {
|
|||
s.name.as_str(),
|
||||
)));
|
||||
}
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
get_conf_val!(s["use_deflate"], false)?;
|
||||
#[cfg(not(feature = "deflate_compression"))]
|
||||
if s.extra.contains_key("use_deflate") {
|
||||
return Err(Error::new(format!(
|
||||
"Configuration error ({}): setting `use_deflate` is set but this version of meli \
|
||||
isn't compiled with DEFLATE support.",
|
||||
s.name.as_str(),
|
||||
)));
|
||||
}
|
||||
get_conf_val!(s["danger_accept_invalid_certs"], false)?;
|
||||
let extra_keys = s
|
||||
.extra
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
//! Connections layers (TCP/fd/TLS/Deflate) to use with remote backends.
|
||||
use std::{os::unix::io::AsRawFd, time::Duration};
|
||||
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
use flate2::{read::DeflateDecoder, write::DeflateEncoder, Compression};
|
||||
#[cfg(any(target_os = "openbsd", target_os = "netbsd", target_os = "haiku"))]
|
||||
use libc::SO_KEEPALIVE as KEEPALIVE_OPTION;
|
||||
|
@ -60,7 +59,6 @@ pub enum Connection {
|
|||
id: Option<&'static str>,
|
||||
trace: bool,
|
||||
},
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate {
|
||||
inner: DeflateEncoder<DeflateDecoder<Box<Self>>>,
|
||||
id: Option<&'static str>,
|
||||
|
@ -105,7 +103,6 @@ impl std::fmt::Debug for Connection {
|
|||
.field(stringify!(id), id)
|
||||
.field(stringify!(inner), inner)
|
||||
.finish(),
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate {
|
||||
ref trace,
|
||||
ref inner,
|
||||
|
@ -136,10 +133,8 @@ macro_rules! syscall {
|
|||
}
|
||||
|
||||
impl Connection {
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
pub const IO_BUF_SIZE: usize = 64 * 1024;
|
||||
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
pub fn deflate(mut self) -> Self {
|
||||
let trace = self.is_trace_enabled();
|
||||
let id = self.id();
|
||||
|
@ -180,7 +175,6 @@ impl Connection {
|
|||
Fd { ref mut trace, .. } => {
|
||||
*trace = val;
|
||||
}
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate { ref mut trace, .. } => *trace = val,
|
||||
}
|
||||
self
|
||||
|
@ -194,7 +188,6 @@ impl Connection {
|
|||
Fd { ref mut id, .. } => {
|
||||
*id = Some(val);
|
||||
}
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate { ref mut id, .. } => *id = Some(val),
|
||||
}
|
||||
self
|
||||
|
@ -208,7 +201,6 @@ impl Connection {
|
|||
Fd { ref mut trace, .. } => {
|
||||
*trace = val;
|
||||
}
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate { ref mut trace, .. } => *trace = val,
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +234,6 @@ impl Connection {
|
|||
.map_err(|err| std::io::Error::from_raw_os_error(err as i32))?;
|
||||
Ok(())
|
||||
}
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate { ref inner, .. } => inner.get_ref().get_ref().set_nonblocking(nonblocking),
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +255,6 @@ impl Connection {
|
|||
#[cfg(feature = "tls")]
|
||||
Tls { ref inner, .. } => inner.get_ref().set_read_timeout(dur),
|
||||
Fd { .. } => Ok(()),
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate { ref inner, .. } => inner.get_ref().get_ref().set_read_timeout(dur),
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +276,6 @@ impl Connection {
|
|||
#[cfg(feature = "tls")]
|
||||
Tls { ref inner, .. } => inner.get_ref().set_write_timeout(dur),
|
||||
Fd { .. } => Ok(()),
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate { ref inner, .. } => inner.get_ref().get_ref().set_write_timeout(dur),
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +360,6 @@ impl Connection {
|
|||
Fd { trace, .. } | Tcp { trace, .. } => *trace,
|
||||
#[cfg(feature = "tls")]
|
||||
Tls { trace, .. } => *trace,
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate { trace, .. } => *trace,
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +369,6 @@ impl Connection {
|
|||
Fd { id, .. } | Tcp { id, .. } => *id,
|
||||
#[cfg(feature = "tls")]
|
||||
Tls { id, .. } => *id,
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate { id, .. } => *id,
|
||||
}
|
||||
}
|
||||
|
@ -408,7 +395,6 @@ impl std::io::Read for Connection {
|
|||
let _ = f.into_raw_fd();
|
||||
ret
|
||||
}
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate { ref mut inner, .. } => inner.read(buf),
|
||||
};
|
||||
if self.is_trace_enabled() {
|
||||
|
@ -463,7 +449,6 @@ impl std::io::Write for Connection {
|
|||
let _ = f.into_raw_fd();
|
||||
ret
|
||||
}
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate { ref mut inner, .. } => inner.write(buf),
|
||||
}
|
||||
}
|
||||
|
@ -480,7 +465,6 @@ impl std::io::Write for Connection {
|
|||
let _ = f.into_raw_fd();
|
||||
ret
|
||||
}
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate { ref mut inner, .. } => inner.flush(),
|
||||
}
|
||||
}
|
||||
|
@ -493,7 +477,6 @@ impl std::os::unix::io::AsRawFd for Connection {
|
|||
#[cfg(feature = "tls")]
|
||||
Tls { ref inner, .. } => inner.get_ref().as_raw_fd(),
|
||||
Fd { ref inner, .. } => *inner,
|
||||
#[cfg(feature = "deflate_compression")]
|
||||
Deflate { ref inner, .. } => inner.get_ref().get_ref().as_raw_fd(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue