]> granicus.if.org Git - neomutt/commitdiff
Mail folder synchronization-related fixes:
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 21 Dec 1998 11:27:23 +0000 (11:27 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 21 Dec 1998 11:27:23 +0000 (11:27 +0000)
- Another situation under which mutt would lose track of the current
  message when maildir folders changed has been removed.

- While synchronizing mbox-type folders, a write error when
  constructing the draft version of the new mail folder would leave
  behind a copy ofthe file containing the draft.  This is most
  annoying if the write error is due to lack of disk space.

mbox.c
mh.c
mx.c

diff --git a/mbox.c b/mbox.c
index 060abea8f17c68fe92d7fd39d30471a64c8c1a4f..9a528f39199974affe4634d6556e5ef1822c230d 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -717,7 +717,10 @@ int mbox_sync_mailbox (CONTEXT *ctx)
       (fp = fdopen (i, "w")) == NULL)
   {
     if (-1 != i)
+    {
       close (i);
+      unlink (tempfile);
+    }
     mutt_error _("Could not create temporary file!");
     goto bail;
   }
@@ -737,6 +740,7 @@ int mbox_sync_mailbox (CONTEXT *ctx)
     mutt_error _("sync: mbox modified, but no modified messages! (report this bug)");
     sleep(5); /* the mutt_error /will/ get cleared! */
     dprint(1, (debugfile, "mbox_sync_mailbox(): no modified messages.\n"));
+    unlink (tempfile);
     goto bail;
   }
 
@@ -768,12 +772,19 @@ int mbox_sync_mailbox (CONTEXT *ctx)
       if (ctx->magic == M_MMDF)
       {
        if (fputs (MMDF_SEP, fp) == EOF)
+       {
+         unlink (tempfile);
          goto bail;
+       }
+         
       }
       else if (ctx->magic == M_KENDRA)
       {
        if (fputs (KENDRA_SEP, fp) == EOF)
+       {
+         unlink (tempfile);
          goto bail;
+       }
       }
 
       /* save the new offset for this message.  we add `offset' because the
@@ -783,7 +794,10 @@ int mbox_sync_mailbox (CONTEXT *ctx)
       newOffset[i - first].hdr = ftell (fp) + offset;
 
       if (mutt_copy_message (fp, ctx, ctx->hdrs[i], M_CM_UPDATE, CH_FROM | CH_UPDATE | CH_UPDATE_LEN) == -1)
+      {
+       unlink (tempfile);
        goto bail;
+      }
 
       /* Since messages could have been deleted, the offsets stored in memory
        * will be wrong, so update what we can, which is the offset of this
@@ -797,13 +811,25 @@ int mbox_sync_mailbox (CONTEXT *ctx)
       switch(ctx->magic)
       {
        case M_MMDF: 
-         if(fputs(MMDF_SEP, fp) == EOF) goto bail; 
+         if(fputs(MMDF_SEP, fp) == EOF) 
+         {
+           unlink (tempfile);
+           goto bail; 
+         }
          break;
        case M_KENDRA:
-         if(fputs(KENDRA_SEP, fp) == EOF) goto bail;
+         if(fputs(KENDRA_SEP, fp) == EOF)
+         {
+           unlink (tempfile);
+           goto bail;
+         }
          break;
        default:
-         if(fputs("\n", fp) == EOF) goto bail;
+         if(fputs("\n", fp) == EOF) 
+         {
+           unlink (tempfile);
+           goto bail;
+         }
       }
     }
   }
diff --git a/mh.c b/mh.c
index f8e2de301b18f7c84a57c2d74e2d7bacbbb0f337..08057903885498762c9ba5bf7257ad6616607158 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -533,13 +533,16 @@ int mh_sync_mailbox (CONTEXT * ctx)
   int i, rc = 0;
   
   i = mh_check_mailbox(ctx, NULL);
+
+#if 0
   if(i == M_REOPENED || i == M_NEW_MAIL)
   {
     set_option(OPTSORTCOLLAPSE);
     mutt_sort_headers(ctx, (i == M_REOPENED));
     unset_option(OPTSORTCOLLAPSE);
   }
-  
+#endif
+
   if(i == M_REOPENED || i == M_NEW_MAIL || i < 0)
     return i;
 
diff --git a/mx.c b/mx.c
index 93c917fe6158f6301d010b2f04a0edffc2279330..e74a8cad046c41a22a80ca28f8eead65bc8d3a45 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -677,6 +677,7 @@ static int sync_mailbox (CONTEXT *ctx)
 
   if (!ctx->quiet)
     mutt_message (_("Writing %s..."), ctx->path);
+
   switch (ctx->magic)
   {
     case M_MBOX:
@@ -699,6 +700,9 @@ static int sync_mailbox (CONTEXT *ctx)
 #endif /* USE_IMAP */
   }
 
+  if (!ctx->quiet && rc == -1)
+    mutt_error ( _("Could not synchronize mailbox %s!"), ctx->path);
+  
 #ifdef BUFFY_SIZE
   if (tmp && tmp->new == 0)
     mutt_update_mailbox (tmp);