From a14983565bdda2640348786f347dc50410eb8d7d Mon Sep 17 00:00:00 2001
From: Brendan Cully <brendan@kublai.com>
Date: Tue, 26 Jul 2005 16:44:20 +0000
Subject: [PATCH] Don't check for the existence of a mailbox we're already in
 when appending. (closes #1842)

---
 imap/imap.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/imap/imap.c b/imap/imap.c
index f5363311..d6c409a1 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -766,8 +766,15 @@ int imap_open_mailbox_append (CONTEXT *ctx)
 
   imap_fix_path (idata, mx.mbox, mailbox, sizeof (mailbox));
 
+  /* We may be appending to the same folder we've selected. */
+  if (!ascii_strcmp(idata->mailbox, mx.mbox))
+  {
+    FREE (&mx.mbox);
+    return 0;
+  }
+
   imap_munge_mbox_name (mbox, sizeof (mbox), mailbox);
-				
+
   if (mutt_bit_isset(idata->capabilities,IMAP4REV1))
     snprintf (buf, sizeof (buf), "STATUS %s (UIDVALIDITY)", mbox);
   else if (mutt_bit_isset(idata->capabilities,STATUS))
@@ -778,10 +785,10 @@ int imap_open_mailbox_append (CONTEXT *ctx)
   {
     /* STATUS not supported */
     mutt_message _("Unable to append to IMAP mailboxes at this server");
-
+    
     goto fail;
   }
-
+  
   r = imap_exec (idata, buf, IMAP_CMD_FAIL_OK);
   if (r == -2)
   {
-- 
2.40.0