diff --git a/Cargo.lock b/Cargo.lock index c4c86972..4e4ef2f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3566,7 +3566,6 @@ dependencies = [ "chrono", "gethostname 0.5.0", "mailparsing", - "memmap2", "percent-encoding", "tempfile", "walkdir", @@ -3649,15 +3648,6 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" -[[package]] -name = "memmap2" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" -dependencies = [ - "libc", -] - [[package]] name = "memmem" version = "0.1.1" diff --git a/Cargo.toml b/Cargo.toml index a6461ae2..44a4579b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -113,7 +113,6 @@ mailparse = "0.14" maplit = "1.0" map_vec = "0.6" memchr = "2.5" -memmap2 = "0.9" metrics = "0.24" metrics-prometheus = "0.8" metrics-tracing-context = "0.17" diff --git a/crates/maildir/Cargo.toml b/crates/maildir/Cargo.toml index 5ca1f966..49652490 100644 --- a/crates/maildir/Cargo.toml +++ b/crates/maildir/Cargo.toml @@ -18,10 +18,6 @@ maintenance = { status = "passively-maintained" } chrono = {workspace=true, default-features=false} gethostname = {workspace=true} mailparsing = { path="../mailparsing" } -memmap2 = { workspace = true, optional = true } - -[features] -mmap = ["memmap2"] [dev-dependencies] percent-encoding = {workspace=true} diff --git a/crates/maildir/src/lib.rs b/crates/maildir/src/lib.rs index 734d71b1..c632c890 100644 --- a/crates/maildir/src/lib.rs +++ b/crates/maildir/src/lib.rs @@ -74,10 +74,7 @@ impl From<&'static str> for MailEntryError { enum MailData { None, - #[cfg(not(feature = "mmap"))] Bytes(Vec), - #[cfg(feature = "mmap")] - File(memmap2::Mmap), } impl MailData { @@ -91,10 +88,7 @@ impl MailData { fn data(&self) -> Option<&[u8]> { match self { Self::None => None, - #[cfg(not(feature = "mmap"))] MailData::Bytes(ref b) => Some(b), - #[cfg(feature = "mmap")] - MailData::File(ref m) => Some(m), } } } @@ -118,20 +112,10 @@ impl MailEntry { fn read_data(&mut self) -> std::io::Result<()> { if self.data.is_none() { - #[cfg(feature = "mmap")] - { - let f = fs::File::open(&self.path)?; - let mmap = unsafe { memmap2::MmapOptions::new().map(&f)? }; - self.data = MailData::File(mmap); - } - - #[cfg(not(feature = "mmap"))] - { - let mut f = fs::File::open(&self.path)?; - let mut d = Vec::::new(); - f.read_to_end(&mut d)?; - self.data = MailData::Bytes(d); - } + let mut f = fs::File::open(&self.path)?; + let mut d = Vec::::new(); + f.read_to_end(&mut d)?; + self.data = MailData::Bytes(d); } Ok(()) }