]> granicus.if.org Git - mutt/commitdiff
Rework mutt_save_confirm to support confirmappend with IMAP mailboxes.
authorBrendan Cully <brendan@kublai.com>
Wed, 27 Jul 2005 00:32:18 +0000 (00:32 +0000)
committerBrendan Cully <brendan@kublai.com>
Wed, 27 Jul 2005 00:32:18 +0000 (00:32 +0000)
I hope I got all cases right.

muttlib.c

index 3321ba9c57346324b8f7c08d9f8a348f4ced9683..2a87349c11e660d8b32f740a51c23760ddade505 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -1256,14 +1256,8 @@ int mutt_save_confirm (const char *s, struct stat *st)
   }
 #endif
 
-  if (stat (s, st) != -1)
+  if (magic > 0 && !mx_access (s, W_OK))
   {
-    if (magic == -1)
-    {
-      mutt_error (_("%s is not a mailbox!"), s);
-      return 1;
-    }
-
     if (option (OPTCONFIRMAPPEND))
     {
       snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s);
@@ -1273,32 +1267,39 @@ int mutt_save_confirm (const char *s, struct stat *st)
        ret = -1;
     }
   }
-  else
+
+  if (stat (s, st) != -1)
   {
+    if (magic == -1)
+    {
+      mutt_error (_("%s is not a mailbox!"), s);
+      return 1;
+    }
+  }
+  else
 #ifdef USE_IMAP
-    if (magic != M_IMAP)
+  if (magic != M_IMAP)
 #endif /* execute the block unconditionally if we don't use imap */
-    {
-      st->st_mtime = 0;
-      st->st_atime = 0;
+  {
+    st->st_mtime = 0;
+    st->st_atime = 0;
 
-      if (errno == ENOENT)
-      {
-       if (option (OPTCONFIRMCREATE))
-       {
-         snprintf (tmp, sizeof (tmp), _("Create %s?"), s);
-         if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
-           ret = 1;
-         else if (rc == -1)
-           ret = -1;
-       }
-      }
-      else
+    if (errno == ENOENT)
+    {
+      if (option (OPTCONFIRMCREATE))
       {
-       mutt_perror (s);
-       return 1;
+       snprintf (tmp, sizeof (tmp), _("Create %s?"), s);
+       if ((rc = mutt_yesorno (tmp, M_YES)) == M_NO)
+         ret = 1;
+       else if (rc == -1)
+         ret = -1;
       }
     }
+    else
+    {
+      mutt_perror (s);
+      return 1;
+    }
   }
 
   CLEARLINE (LINES-1);