notmuch: fix wrong mailbox path in save()

mailbox path was passed to save_to_mailbox() with a cur/ tail and
save_to_mailbox() added an extra cur/ tail
async
Manos Pitsidianakis 2020-03-18 19:22:17 +02:00
parent 7a770c7f7b
commit 61be6e4c96
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
2 changed files with 11 additions and 14 deletions

View File

@ -1012,6 +1012,16 @@ impl MaildirType {
}
pub fn save_to_mailbox(mut path: PathBuf, bytes: &[u8], flags: Option<Flag>) -> Result<()> {
for d in &["cur", "new", "tmp"] {
path.push(d);
if !path.is_dir() {
return Err(MeliError::new(format!(
"{} is not a valid maildir mailbox",
path.display()
)));
}
path.pop();
}
path.push("cur");
{
let mut rand_buf = [0u8; 16];

View File

@ -448,24 +448,11 @@ impl MailBackend for NotmuchDb {
}
fn save(&self, bytes: &[u8], _mailbox: &str, flags: Option<Flag>) -> Result<()> {
let mut path = self
let path = self
.save_messages_to
.as_ref()
.unwrap_or(&self.path)
.to_path_buf();
if !(path.ends_with("cur") || path.ends_with("new") || path.ends_with("tmp")) {
for d in &["cur", "new", "tmp"] {
path.push(d);
if !path.is_dir() {
return Err(MeliError::new(format!(
"{} is not a valid maildir mailbox",
path.display()
)));
}
path.pop();
}
path.push("cur");
}
crate::backends::MaildirType::save_to_mailbox(path, bytes, flags)
}