From: Kevin McCarthy Date: Wed, 20 Mar 2019 09:38:16 +0000 (+0800) Subject: Alternative close implementation. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=refs%2Fheads%2Fkevin%2Fimap-delete-current;p=mutt Alternative close implementation. --- diff --git a/browser.c b/browser.c index 90e420d3..a78c66bf 100644 --- 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)); diff --git a/imap/imap.c b/imap/imap.c index 9f13eae8..18067435 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -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; } diff --git a/imap/imap.h b/imap/imap.h index fe99472b..20c53d9f 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -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);