mx.mbox);
if (mutt_yesorno (msg, MUTT_NO) == MUTT_YES)
{
- if (!imap_delete_mailbox (Context, mx))
+ if (!imap_delete_mailbox (Context, mx,
+ Context &&
+ !mutt_strcmp (state.entry[nentry].name, Context->realpath)))
{
- /* Some IMAP servers react badly to the currently selected mailbox
- * being deleted, so close in that case */
- if (Context &&
- !mutt_strcmp (state.entry[nentry].name, Context->realpath))
- {
- Context->deleted = 0;
- mx_fastclose_mailbox (Context);
- FREE (&Context);
- }
/* free the mailbox from the browser */
FREE (&((state.entry)[nentry].name));
FREE (&((state.entry)[nentry].desc));
return rc;
}
-int imap_delete_mailbox (CONTEXT* ctx, IMAP_MBOX mx)
+int imap_delete_mailbox (CONTEXT* ctx, IMAP_MBOX mx, int close_context)
{
char buf[LONG_STRING*2], mbox[LONG_STRING];
IMAP_DATA *idata;
if (imap_exec ((IMAP_DATA*) idata, buf, 0) != 0)
return -1;
+ /* Some IMAP servers react badly to the currently selected mailbox
+ * being deleted, so issue a CLOSE. imap_close_mailbox() queue's
+ * the CLOSE command instead of sending it right away, so we issue
+ * the command ourself here. */
+ if (close_context)
+ {
+ imap_exec (idata, "CLOSE", 0);
+ idata->state = IMAP_AUTHENTICATED;
+ mx_fastclose_mailbox (Context);
+ FREE (&Context);
+ }
+
return 0;
}
/* imap.c */
int imap_access (const char *path);
int imap_check_mailbox (CONTEXT *ctx, int *index_hint, int force);
-int imap_delete_mailbox (CONTEXT* idata, IMAP_MBOX mx);
+int imap_delete_mailbox (CONTEXT* idata, IMAP_MBOX mx, int close_context);
int imap_sync_mailbox (CONTEXT *ctx, int expunge, int *index_hint);
int imap_close_mailbox (CONTEXT *ctx);
int imap_buffy_check (int force, int check_stats);