From: Kevin McCarthy Date: Tue, 19 Mar 2019 09:06:33 +0000 (+0800) Subject: Send CLOSE when deleting the current mailbox in IMAP. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1f4ef80ce80450b74ada1c84b96972cefd5494ac;p=mutt Send CLOSE when deleting the current mailbox in IMAP. Some IMAP servers don't like it if the currently selected mailbox is deleted. In those cases, send a CLOSE command before issuing any other commands. --- diff --git a/browser.c b/browser.c index d06780cc..90e420d3 100644 --- a/browser.c +++ b/browser.c @@ -1096,6 +1096,15 @@ void _mutt_buffer_select_file (BUFFER *f, int flags, char ***files, int *numfile { if (!imap_delete_mailbox (Context, mx)) { + /* 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));