mirror of
https://github.com/mailscope/kumomta.git
synced 2026-10-19 21:12:26 +00:00
maildir: remove mmap feature
we're not using it and it simplifies the code a little to remove it. refs: https://github.com/KumoCorp/kumomta/issues/109
This commit is contained in:
Generated
-10
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -74,10 +74,7 @@ impl From<&'static str> for MailEntryError {
|
||||
|
||||
enum MailData {
|
||||
None,
|
||||
#[cfg(not(feature = "mmap"))]
|
||||
Bytes(Vec<u8>),
|
||||
#[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::<u8>::new();
|
||||
f.read_to_end(&mut d)?;
|
||||
self.data = MailData::Bytes(d);
|
||||
}
|
||||
let mut f = fs::File::open(&self.path)?;
|
||||
let mut d = Vec::<u8>::new();
|
||||
f.read_to_end(&mut d)?;
|
||||
self.data = MailData::Bytes(d);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user