imap: treat \NoSelect mailboxes as empty

\NoSelect are mailboxes that can't be selected, thus treat them as if
they are empty.
memfd
Manos Pitsidianakis 2019-12-10 23:54:19 +02:00
parent ad7c91bc29
commit a20e08eb43
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
3 changed files with 15 additions and 2 deletions

View File

@ -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);

View File

@ -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(),
})

View File

@ -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) {