Browse Source

imap: small fixes

tags/alpha-0.6.0
Manos Pitsidianakis 9 months ago
parent
commit
5a5408ecd5
Signed by: epilys GPG Key ID: 73627C2F690DF710
3 changed files with 13 additions and 8 deletions
  1. +9
    -7
      melib/src/backends/imap.rs
  2. +2
    -0
      melib/src/backends/imap/connection.rs
  3. +2
    -1
      melib/src/backends/imap/protocol_parser.rs

+ 9
- 7
melib/src/backends/imap.rs View File

@ -682,6 +682,13 @@ impl MailBackend for ImapType {
{
let mailboxes = uid_store.mailboxes.lock().await;
if mailboxes.values().any(|f| f.path == path) {
return Err(MeliError::new(format!(
"Mailbox named `{}` already exists.",
path,
)));
}
for root_mailbox in mailboxes.values().filter(|f| f.parent.is_none()) {
if path.starts_with(&root_mailbox.name) {
debug!("path starts with {:?}", &root_mailbox);
@ -693,12 +700,8 @@ impl MailBackend for ImapType {
}
}
if mailboxes.values().any(|f| f.path == path) {
return Err(MeliError::new(format!(
"Mailbox named `{}` already exists.",
path,
)));
}
/* FIXME Do not try to CREATE a sub-mailbox in a mailbox that has the \Noinferiors
* flag set. */
}
let mut response = String::with_capacity(8 * 1024);
@ -1387,7 +1390,6 @@ async fn fetch_hlpr(
permissions.set_flags = !examine_response.read_only;
permissions.rename_messages = !examine_response.read_only;
permissions.delete_messages = !examine_response.read_only;
permissions.delete_messages = !examine_response.read_only;
mailbox_exists
.lock()
.unwrap()

+ 2
- 0
melib/src/backends/imap/connection.rs View File

@ -525,10 +525,12 @@ impl ImapConnection {
ret.push_str(&response);
}
ImapResponse::No(ref response_code) => {
//FIXME return error
debug!("Received NO response: {:?} {:?}", response_code, response);
ret.push_str(&response);
}
ImapResponse::Bad(ref response_code) => {
//FIXME return error
debug!("Received BAD response: {:?} {:?}", response_code, response);
ret.push_str(&response);
}

+ 2
- 1
melib/src/backends/imap/protocol_parser.rs View File

@ -539,6 +539,7 @@ pub fn uid_fetch_response(input: &str) -> ImapParseResult>
let mut has_attachments = false;
while i < input.len() {
eat_whitespace!(break);
bounds!(break);
if input[i..].starts_with("UID ") {
i += "UID ".len();
@ -877,12 +878,12 @@ pub enum UntaggedResponse {
}
pub fn untagged_responses(input: &[u8]) -> IResult<&[u8], Option<UntaggedResponse>> {
debug!("Parse untagged response from {:?}", to_str!(input));
let (input, _) = tag("* ")(input)?;
let (input, num) = map_res(digit1, |s| usize::from_str(to_str!(s)))(input)?;
let (input, _) = tag(" ")(input)?;
let (input, _tag) = take_until("\r\n")(input)?;
let (input, _) = tag("\r\n")(input)?;
debug!("Parse untagged response from {:?}", to_str!(input));
Ok((input, {
use UntaggedResponse::*;
match _tag {

Loading…
Cancel
Save