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/ tailasync
parent
7a770c7f7b
commit
61be6e4c96
|
@ -1012,6 +1012,16 @@ impl MaildirType {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save_to_mailbox(mut path: PathBuf, bytes: &[u8], flags: Option<Flag>) -> Result<()> {
|
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");
|
path.push("cur");
|
||||||
{
|
{
|
||||||
let mut rand_buf = [0u8; 16];
|
let mut rand_buf = [0u8; 16];
|
||||||
|
|
|
@ -448,24 +448,11 @@ impl MailBackend for NotmuchDb {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save(&self, bytes: &[u8], _mailbox: &str, flags: Option<Flag>) -> Result<()> {
|
fn save(&self, bytes: &[u8], _mailbox: &str, flags: Option<Flag>) -> Result<()> {
|
||||||
let mut path = self
|
let path = self
|
||||||
.save_messages_to
|
.save_messages_to
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap_or(&self.path)
|
.unwrap_or(&self.path)
|
||||||
.to_path_buf();
|
.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)
|
crate::backends::MaildirType::save_to_mailbox(path, bytes, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue