From c6406c3da6d7944dbb709111cdac8ef4c2d2fa35 Mon Sep 17 00:00:00 2001 From: Brendan Cully Date: Sat, 31 Mar 2007 16:07:36 -0700 Subject: [PATCH] Allow IMAP FCC to reconnect if append fails (closes: #890) --- imap/command.c | 2 +- imap/imap.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/imap/command.c b/imap/command.c index 9e0647e8..96aadc24 100644 --- a/imap/command.c +++ b/imap/command.c @@ -270,7 +270,7 @@ int imap_exec (IMAP_DATA* idata, const char* cmdstr, int flags) if (rc != IMAP_CMD_OK) { - if (flags & IMAP_CMD_FAIL_OK) + if (flags & IMAP_CMD_FAIL_OK && idata->status != IMAP_FATAL) return -2; dprint (1, (debugfile, "imap_exec: command failed: %s\n", idata->buf)); diff --git a/imap/imap.c b/imap/imap.c index 97844107..d788b1ba 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -63,6 +63,7 @@ int imap_access (const char* path, int flags) char buf[LONG_STRING]; char mailbox[LONG_STRING]; char mbox[LONG_STRING]; + int rc; if (imap_parse_path (path, &mx)) return -1; @@ -96,10 +97,10 @@ int imap_access (const char* path, int flags) return -1; } - if (imap_exec (idata, buf, IMAP_CMD_FAIL_OK) < 0) + if ((rc = imap_exec (idata, buf, IMAP_CMD_FAIL_OK)) < 0) { dprint (1, (debugfile, "imap_access: Can't check STATUS of %s\n", mbox)); - return -1; + return rc; } return 0; @@ -341,6 +342,8 @@ IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags) } if (flags & M_IMAP_CONN_NOSELECT && idata && idata->state >= IMAP_SELECTED) continue; + if (idata && idata->status == IMAP_FATAL) + continue; break; } if (!conn) @@ -771,6 +774,7 @@ int imap_open_mailbox_append (CONTEXT *ctx) char buf[LONG_STRING]; char mailbox[LONG_STRING]; IMAP_MBOX mx; + int rc; if (imap_parse_path (ctx->path, &mx)) return -1; @@ -793,9 +797,12 @@ int imap_open_mailbox_append (CONTEXT *ctx) FREE (&mx.mbox); /* really we should also check for W_OK */ - if (!imap_access (ctx->path, F_OK)) + if ((rc = imap_access (ctx->path, F_OK)) == 0) return 0; + if (rc == -1) + return -1; + snprintf (buf, sizeof (buf), _("Create %s?"), mailbox); if (option (OPTCONFIRMCREATE) && mutt_yesorno (buf, 1) < 1) return -1; -- 2.40.0