]> granicus.if.org Git - mutt/commitdiff
Send CLOSE when deleting the current mailbox in IMAP.
authorKevin McCarthy <kevin@8t8.us>
Tue, 19 Mar 2019 09:06:33 +0000 (17:06 +0800)
committerKevin McCarthy <kevin@8t8.us>
Tue, 19 Mar 2019 09:06:33 +0000 (17:06 +0800)
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.

browser.c

index d06780cce54b2d1b94142fc21dbf05748e82551c..90e420d3af553ba77d3b22b8123eedb200f729c9 100644 (file)
--- 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));