{
dprint (2, (debugfile, "cmd_finish: Expunging mailbox\n"));
imap_expunge_mailbox (idata);
- idata->reopen &= ~(IMAP_EXPUNGE_PENDING|IMAP_NEWMAIL_PENDING);
+ /* Detect whether we've gotten unexpected EXPUNGE messages */
+ if (idata->reopen & IMAP_EXPUNGE_PENDING &&
+ !(idata->reopen & IMAP_EXPUNGE_EXPECTED))
+ idata->check_status = IMAP_EXPUNGE_PENDING;
+ idata->reopen &= ~(IMAP_EXPUNGE_PENDING | IMAP_NEWMAIL_PENDING |
+ IMAP_EXPUNGE_EXPECTED);
}
}
mutt_bit_isset(idata->rights, IMAP_ACL_DELETE))
{
mutt_message _("Expunging messages from server...");
+ /* Set expunge bit so we don't get spurious reopened messages */
+ idata->reopen |= IMAP_EXPUNGE_EXPECTED;
if (imap_exec (idata, "EXPUNGE", 0) != 0)
{
imap_error ("imap_sync_mailbox: EXPUNGE failed", idata->cmd.buf);
idata->check_status &= ~IMAP_NEWMAIL_PENDING;
return M_NEW_MAIL;
}
- /* TODO: we should be able to detect external changes and return
- * M_REOPENED here. */
-
+ if (idata->check_status & IMAP_EXPUNGE_PENDING)
+ {
+ idata->check_status &= ~IMAP_EXPUNGE_PENDING;
+ return M_REOPENED;
+ }
+
return 0;
}
#define SEQLEN 5
-#define IMAP_REOPEN_ALLOW (1<<0)
-#define IMAP_EXPUNGE_PENDING (1<<1)
-#define IMAP_NEWMAIL_PENDING (1<<2)
+#define IMAP_REOPEN_ALLOW (1<<0)
+#define IMAP_EXPUNGE_PENDING (1<<1)
+#define IMAP_NEWMAIL_PENDING (1<<2)
+#define IMAP_EXPUNGE_EXPECTED (1<<3)
/* imap_exec flags (see imap_exec) */
#define IMAP_CMD_FAIL_OK (1<<0)