Browse Source

imap: treat \NoSelect mailboxes as empty

\NoSelect are mailboxes that can't be selected, thus treat them as if
they are empty.
async
Manos Pitsidianakis 2 years ago
parent
commit
a20e08eb43
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 9
      melib/src/backends/imap.rs
  2. 2
      melib/src/backends/imap/folder.rs
  3. 6
      melib/src/backends/imap/protocol_parser.rs

9
melib/src/backends/imap.rs

@ -157,12 +157,17 @@ impl MailBackend for ImapType {
let can_create_flags = self.can_create_flags.clone();
let folder_path = folder.path().to_string();
let folder_hash = folder.hash();
let (permissions, folder_exists) = {
let (permissions, folder_exists, no_select) = {
let f = &self.folders.read().unwrap()[&folder_hash];
(f.permissions.clone(), f.exists.clone())
(f.permissions.clone(), f.exists.clone(), f.no_select)
};
let connection = self.connection.clone();
let closure = move |_work_context| {
if no_select {
tx.send(AsyncStatus::Payload(Ok(Vec::new()))).unwrap();
tx.send(AsyncStatus::Finished).unwrap();
return;
}
let connection = connection.clone();
let tx = tx.clone();
let mut response = String::with_capacity(8 * 1024);

2
melib/src/backends/imap/folder.rs

@ -28,6 +28,7 @@ pub struct ImapFolder {
pub(super) name: String,
pub(super) parent: Option<FolderHash>,
pub(super) children: Vec<FolderHash>,
pub no_select: bool,
pub permissions: Arc<Mutex<FolderPermissions>>,
pub exists: Arc<Mutex<usize>>,
@ -61,6 +62,7 @@ impl BackendFolder for ImapFolder {
name: self.name.clone(),
parent: self.parent,
children: self.children.clone(),
no_select: self.no_select,
permissions: self.permissions.clone(),
exists: self.exists.clone(),
})

6
melib/src/backends/imap/protocol_parser.rs

@ -54,6 +54,12 @@ named!(
>> ({
let separator: u8 = separator[0];
let mut f = ImapFolder::default();
f.no_select = false;
for p in properties.split(|&b| b == b' ') {
if p.eq_ignore_ascii_case(b"\\NoSelect") {
f.no_select = true;
}
}
f.hash = get_path_hash!(path);
f.path = String::from_utf8_lossy(path).into();
f.name = if let Some(pos) = path.iter().rposition(|&c| c == separator) {

Loading…
Cancel
Save