- imap_error ("imap_copy_messages", idata->buf);
- goto fail;
- }
- dprint (2, (debugfile, "imap_copy_messages: server suggests TRYCREATE\n"));
- snprintf (mmbox, sizeof (mmbox), _("Create %s?"), mbox);
- if (option (OPTCONFIRMCREATE) && mutt_yesorno (mmbox, 1) < 1)
- {
- mutt_clear_error ();
- goto fail;
+ if (triedcreate)
+ {
+ dprint (1, (debugfile, "Already tried to create mailbox %s\n", mbox));
+ break;
+ }
+ /* bail out if command failed for reasons other than nonexistent target */
+ if (ascii_strncasecmp (imap_get_qualifier (idata->buf), "[TRYCREATE]", 11))
+ break;
+ dprint (3, (debugfile, "imap_copy_messages: server suggests TRYCREATE\n"));
+ snprintf (prompt, sizeof (prompt), _("Create %s?"), mbox);
+ if (option (OPTCONFIRMCREATE) && mutt_yesorno (prompt, 1) < 1)
+ {
+ mutt_clear_error ();
+ goto out;
+ }
+ if (imap_create_mailbox (idata, mbox) < 0)
+ break;
+ triedcreate = 1;