]> granicus.if.org Git - mutt/commitdiff
Fix some issues with synching of maildir/mh folders. Problems noted
authorThomas Roessler <roessler@does-not-exist.org>
Sun, 11 Jun 2000 19:05:12 +0000 (19:05 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Sun, 11 Jun 2000 19:05:12 +0000 (19:05 +0000)
by Byrial Jensen.

mh.c
mx.c

diff --git a/mh.c b/mh.c
index 46cfbab069fd5a07c3fbbaa0775c196f8db18a5b..2d970d21287e505cadcb6e40c3b8a591ad081c9a 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -477,6 +477,9 @@ int maildir_commit_message (CONTEXT *ctx, MESSAGE *msg, HEADER *hdr)
   char full[_POSIX_PATH_MAX];
   char *s;
 
+  if (safe_fclose (&msg->fp) != 0)
+    return -1;
+  
   /* extract the subdir */
   s = strrchr (msg->path, '/') + 1;
   strfcpy (subdir, s, 4);
@@ -529,6 +532,9 @@ int mh_commit_message (CONTEXT *ctx, MESSAGE *msg, HEADER *hdr)
   char path[_POSIX_PATH_MAX];
   char tmp[16];
 
+  if (safe_fclose (&msg->fp) != 0)
+    return -1;
+  
   if ((dirp = opendir (ctx->path)) == NULL)
   {
     mutt_perror (ctx->path);
@@ -596,6 +602,7 @@ static int mh_sync_message (CONTEXT *ctx, int msgno)
   MESSAGE *dest;
 
   int rc;
+  short restore = 1;
   char oldpath[_POSIX_PATH_MAX];
   char newpath[_POSIX_PATH_MAX];
   char partpath[_POSIX_PATH_MAX];
@@ -621,7 +628,10 @@ static int mh_sync_message (CONTEXT *ctx, int msgno)
     mx_close_message (&dest);
 
     if (rc == 0)
+    {
       unlink (oldpath);
+      restore = 0;
+    }
 
     /* 
      * Try to move the new message to the old place.
@@ -645,9 +655,10 @@ static int mh_sync_message (CONTEXT *ctx, int msgno)
        mutt_str_replace (&h->path, partpath);
     }
   }
-  else mx_close_message (&dest);
+  else 
+    mx_close_message (&dest);
 
-  if (rc == -1)
+  if (rc == -1 && restore)
   {
     h->content->offset = old_body_offset;
     h->content->length = old_body_length;
diff --git a/mx.c b/mx.c
index dc6da4a07de2e75e3a9975edbcfa76db73066fa8..2fbc393d9cd7b3050884b928d9826786f5b81696 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -1344,15 +1344,13 @@ int mx_commit_message (MESSAGE *msg, CONTEXT *ctx)
     
     case M_MAILDIR:
     {
-      if ((r = safe_fclose (&msg->fp)) == 0)
-       r = maildir_commit_message (ctx, msg, NULL);
+      r = maildir_commit_message (ctx, msg, NULL);
       break;
     }
     
     case M_MH:
     {
-      if ((r = safe_fclose (&msg->fp)) == 0)
-       r = mh_commit_message (ctx, msg, NULL);
+      r = mh_commit_message (ctx, msg, NULL);
       break;
     }
   }