]> granicus.if.org Git - mutt/commitdiff
Alternative close implementation. kevin/imap-delete-current
authorKevin McCarthy <kevin@8t8.us>
Wed, 20 Mar 2019 09:38:16 +0000 (17:38 +0800)
committerKevin McCarthy <kevin@8t8.us>
Wed, 20 Mar 2019 09:38:16 +0000 (17:38 +0800)
browser.c
imap/imap.c
imap/imap.h

index 90e420d3af553ba77d3b22b8123eedb200f729c9..a78c66bfe829817013013764cb357be5cd072e6a 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -1094,17 +1094,10 @@ void _mutt_buffer_select_file (BUFFER *f, int flags, char ***files, int *numfile
                     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));
index 9f13eae888de8b3451a40f07d3bc5ed0af62c1e6..1806743532354a1ee69bacdbfd2bb9f076ad96ad 100644 (file)
@@ -150,7 +150,7 @@ int imap_rename_mailbox (IMAP_DATA* idata, IMAP_MBOX* mx, const char* newname)
   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;
@@ -175,6 +175,18 @@ int imap_delete_mailbox (CONTEXT* ctx, IMAP_MBOX mx)
   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;
 }
 
index fe99472b7e8d063a5740581595c1da02dc6cff46..20c53d9f1025165238463cfd2e253bfbf32d925e 100644 (file)
@@ -34,7 +34,7 @@ typedef struct
 /* 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);