sync: select destination read-write so PERMANENTFLAGS is real (flags were dropped)
This commit is contained in:
1 parent
7e01130172
commit
f723e1eaa8
3 files changed
+14
-4
No files matched your search
+11
-1
@@ -60,6 +60,9 @@ pub struct SelectInfo {
|
||||
pub exists: u32,
|
||||
pub uidvalidity: Option<u32>,
|
||||
pub permanent_flags: Option<Vec<String>>,
|
||||
/// EXAMINE / [READ-ONLY]: PERMANENTFLAGS is then empty and says nothing
|
||||
/// about what APPEND will keep.
|
||||
pub read_only: bool,
|
||||
}
|
||||
|
||||
impl SelectInfo {
|
||||
@@ -67,6 +70,7 @@ impl SelectInfo {
|
||||
pub fn accepts_flag(&self, f: &str) -> bool {
|
||||
match &self.permanent_flags {
|
||||
None => true,
|
||||
Some(_) if self.read_only => true,
|
||||
Some(p) => {
|
||||
p.iter().any(|x| x.eq_ignore_ascii_case(f)) || (!f.starts_with('\\') && p.iter().any(|x| x == "\\*"))
|
||||
}
|
||||
@@ -426,7 +430,10 @@ impl Client {
|
||||
let mut args = vec![Arg::Raw(format!("{verb} "))];
|
||||
args.push(mailbox_arg(wire));
|
||||
let r = self.run(args, &format!("{verb} {wire}")).await?;
|
||||
let mut info = SelectInfo::default();
|
||||
let mut info = SelectInfo {
|
||||
read_only: readonly || r.status.code.as_deref().is_some_and(|c| c.eq_ignore_ascii_case("READ-ONLY")),
|
||||
..Default::default()
|
||||
};
|
||||
for u in &r.untagged {
|
||||
if let Some(s) = u.status() {
|
||||
if let Some(code) = s.code {
|
||||
@@ -673,5 +680,8 @@ mod tests {
|
||||
assert!(!s.accepts_flag("\\Flagged"));
|
||||
let s = SelectInfo { permanent_flags: Some(vec!["\\Seen".into()]), ..Default::default() };
|
||||
assert!(!s.accepts_flag("$Forwarded"));
|
||||
// EXAMINE: PERMANENTFLAGS () is meaningless for APPEND
|
||||
let s = SelectInfo { permanent_flags: Some(vec![]), read_only: true, ..Default::default() };
|
||||
assert!(s.accepts_flag("\\Seen"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user