mirror of
https://github.com/soywod/himalaya.git
synced 2024-11-22 11:00:19 +00:00
check for absolute and relative maildir paths
This commit is contained in:
parent
d79c6c40a7
commit
1f01202262
2 changed files with 13 additions and 10 deletions
|
@ -47,13 +47,16 @@ impl<'a> MaildirBackend<'a> {
|
|||
self.validate_mdir_path(self.mdir.path().to_owned())
|
||||
.map(maildir::Maildir::from)
|
||||
} else {
|
||||
// If the dir is a valid maildir path, creates a maildir instance from it.
|
||||
// If the dir is a valid maildir path, creates a maildir
|
||||
// instance from it. Checks for absolute path first,
|
||||
self.validate_mdir_path(dir.into())
|
||||
// then for relative path,
|
||||
.or_else(|_| self.validate_mdir_path(self.mdir.path().join(dir)))
|
||||
.or_else(|_| {
|
||||
// Otherwise creates a maildir instance from a
|
||||
// otherwise creates a maildir instance from a
|
||||
// maildir subdirectory by adding a "." in front
|
||||
// of the name as described in the spec:
|
||||
// https://cr.yp.to/proto/maildir.html
|
||||
// https://cr.yp.to/proto/maildir.html.
|
||||
let dir = self
|
||||
.account_config
|
||||
.mailboxes
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
use anyhow::{anyhow, Context, Error, Result};
|
||||
use chrono::DateTime;
|
||||
use log::{debug, info, trace};
|
||||
use log::trace;
|
||||
use std::{
|
||||
convert::{TryFrom, TryInto},
|
||||
ops::{Deref, DerefMut},
|
||||
|
@ -125,7 +125,7 @@ impl<'a> TryFrom<RawMaildirEnvelope> for MaildirEnvelope {
|
|||
type Error = Error;
|
||||
|
||||
fn try_from(mut mail_entry: RawMaildirEnvelope) -> Result<Self, Self::Error> {
|
||||
info!("begin: try building envelope from maildir parsed mail");
|
||||
trace!(">> build envelope from maildir parsed mail");
|
||||
|
||||
let mut envelope = Self::default();
|
||||
|
||||
|
@ -139,14 +139,14 @@ impl<'a> TryFrom<RawMaildirEnvelope> for MaildirEnvelope {
|
|||
.parsed()
|
||||
.context("cannot parse maildir mail entry")?;
|
||||
|
||||
debug!("begin: parse headers");
|
||||
trace!(">> parse headers");
|
||||
for h in parsed_mail.get_headers() {
|
||||
let k = h.get_key();
|
||||
debug!("header key: {:?}", k);
|
||||
trace!("header key: {:?}", k);
|
||||
|
||||
let v = rfc2047_decoder::decode(h.get_value_raw())
|
||||
.context(format!("cannot decode value from header {:?}", k))?;
|
||||
debug!("header value: {:?}", v);
|
||||
trace!("header value: {:?}", v);
|
||||
|
||||
match k.to_lowercase().as_str() {
|
||||
"date" => {
|
||||
|
@ -182,10 +182,10 @@ impl<'a> TryFrom<RawMaildirEnvelope> for MaildirEnvelope {
|
|||
_ => (),
|
||||
}
|
||||
}
|
||||
debug!("end: parse headers");
|
||||
trace!("<< parse headers");
|
||||
|
||||
trace!("envelope: {:?}", envelope);
|
||||
info!("end: try building envelope from maildir parsed mail");
|
||||
trace!("<< build envelope from maildir parsed mail");
|
||||
Ok(envelope)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue