imap: treat \NoSelect mailboxes as empty
\NoSelect are mailboxes that can't be selected, thus treat them as if they are empty.memfd
parent
ad7c91bc29
commit
a20e08eb43
|
@ -157,12 +157,17 @@ impl MailBackend for ImapType {
|
||||||
let can_create_flags = self.can_create_flags.clone();
|
let can_create_flags = self.can_create_flags.clone();
|
||||||
let folder_path = folder.path().to_string();
|
let folder_path = folder.path().to_string();
|
||||||
let folder_hash = folder.hash();
|
let folder_hash = folder.hash();
|
||||||
let (permissions, folder_exists) = {
|
let (permissions, folder_exists, no_select) = {
|
||||||
let f = &self.folders.read().unwrap()[&folder_hash];
|
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 connection = self.connection.clone();
|
||||||
let closure = move |_work_context| {
|
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 connection = connection.clone();
|
||||||
let tx = tx.clone();
|
let tx = tx.clone();
|
||||||
let mut response = String::with_capacity(8 * 1024);
|
let mut response = String::with_capacity(8 * 1024);
|
||||||
|
|
|
@ -28,6 +28,7 @@ pub struct ImapFolder {
|
||||||
pub(super) name: String,
|
pub(super) name: String,
|
||||||
pub(super) parent: Option<FolderHash>,
|
pub(super) parent: Option<FolderHash>,
|
||||||
pub(super) children: Vec<FolderHash>,
|
pub(super) children: Vec<FolderHash>,
|
||||||
|
pub no_select: bool,
|
||||||
|
|
||||||
pub permissions: Arc<Mutex<FolderPermissions>>,
|
pub permissions: Arc<Mutex<FolderPermissions>>,
|
||||||
pub exists: Arc<Mutex<usize>>,
|
pub exists: Arc<Mutex<usize>>,
|
||||||
|
@ -61,6 +62,7 @@ impl BackendFolder for ImapFolder {
|
||||||
name: self.name.clone(),
|
name: self.name.clone(),
|
||||||
parent: self.parent,
|
parent: self.parent,
|
||||||
children: self.children.clone(),
|
children: self.children.clone(),
|
||||||
|
no_select: self.no_select,
|
||||||
permissions: self.permissions.clone(),
|
permissions: self.permissions.clone(),
|
||||||
exists: self.exists.clone(),
|
exists: self.exists.clone(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -54,6 +54,12 @@ named!(
|
||||||
>> ({
|
>> ({
|
||||||
let separator: u8 = separator[0];
|
let separator: u8 = separator[0];
|
||||||
let mut f = ImapFolder::default();
|
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.hash = get_path_hash!(path);
|
||||||
f.path = String::from_utf8_lossy(path).into();
|
f.path = String::from_utf8_lossy(path).into();
|
||||||
f.name = if let Some(pos) = path.iter().rposition(|&c| c == separator) {
|
f.name = if let Some(pos) = path.iter().rposition(|&c| c == separator) {
|
||||||
|
|
Loading…
Reference in New Issue