mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
imap: expunge folder before IDLE if needed
This ensures Inbox is expunged timely in setups that don't watch DeltaChat folder.
This commit is contained in:
committed by
link2xt
parent
d3eb209d27
commit
1e84e81e7d
@@ -1542,7 +1542,6 @@ class TestOnlineAccount:
|
|||||||
assert msg.is_encrypted(), "Message is not encrypted"
|
assert msg.is_encrypted(), "Message is not encrypted"
|
||||||
assert msg.chat == ac2.create_chat(ac4)
|
assert msg.chat == ac2.create_chat(ac4)
|
||||||
|
|
||||||
@pytest.mark.xfail
|
|
||||||
def test_immediate_autodelete(self, acfactory, lp):
|
def test_immediate_autodelete(self, acfactory, lp):
|
||||||
ac1 = acfactory.get_online_configuring_account()
|
ac1 = acfactory.get_online_configuring_account()
|
||||||
ac2 = acfactory.get_online_configuring_account(mvbox=False, move=False, sentbox=False)
|
ac2 = acfactory.get_online_configuring_account(mvbox=False, move=False, sentbox=False)
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ impl Imap {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Issues a CLOSE command if selected folder needs expunge.
|
||||||
|
pub(crate) async fn maybe_close_folder(&mut self, context: &Context) -> Result<()> {
|
||||||
|
if self.config.selected_folder_needs_expunge {
|
||||||
|
self.close_folder(context).await?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// select a folder, possibly update uid_validity and, if needed,
|
/// select a folder, possibly update uid_validity and, if needed,
|
||||||
/// expunge the folder to remove delete-marked messages.
|
/// expunge the folder to remove delete-marked messages.
|
||||||
pub(super) async fn select_folder<S: AsRef<str>>(
|
pub(super) async fn select_folder<S: AsRef<str>>(
|
||||||
@@ -76,10 +84,7 @@ impl Imap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// deselect existing folder, if needed (it's also done implicitly by SELECT, however, without EXPUNGE then)
|
// deselect existing folder, if needed (it's also done implicitly by SELECT, however, without EXPUNGE then)
|
||||||
let needs_expunge = { self.config.selected_folder_needs_expunge };
|
self.maybe_close_folder(context).await?;
|
||||||
if needs_expunge {
|
|
||||||
self.close_folder(context).await?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// select new folder
|
// select new folder
|
||||||
if let Some(ref folder) = folder {
|
if let Some(ref folder) = folder {
|
||||||
|
|||||||
@@ -74,6 +74,13 @@ async fn inbox_loop(ctx: Context, started: Sender<()>, inbox_handlers: ImapConne
|
|||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
jobs_loaded = 0;
|
jobs_loaded = 0;
|
||||||
|
|
||||||
|
// Expunge folder if needed, e.g. if some jobs have
|
||||||
|
// deleted messages on the server.
|
||||||
|
if let Err(err) = connection.maybe_close_folder(&ctx).await {
|
||||||
|
warn!(ctx, "failed to close folder: {:?}", err);
|
||||||
|
}
|
||||||
|
|
||||||
info = if ctx.get_config_bool(Config::InboxWatch).await {
|
info = if ctx.get_config_bool(Config::InboxWatch).await {
|
||||||
fetch_idle(&ctx, &mut connection, Config::ConfiguredInboxFolder).await
|
fetch_idle(&ctx, &mut connection, Config::ConfiguredInboxFolder).await
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user