]> granicus.if.org Git - neomutt/commitdiff
don't rename in DB before mx commit
authorKarel Zak <kzak@redhat.com>
Wed, 9 May 2012 07:44:13 +0000 (09:44 +0200)
committerRichard Russon <rich@flatcap.org>
Mon, 4 Apr 2016 15:30:05 +0000 (16:30 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
copy.c
mh.c
mx.c

diff --git a/copy.c b/copy.c
index 6ce6fc10f914b4f48a96d0efaa5b462fe4383f55..e5610c28e94274e67d81933f5d839e1cb6f8dd1a 100644 (file)
--- a/copy.c
+++ b/copy.c
 #include <ctype.h>
 #include <unistd.h> /* needed for SEEK_SET under SunOS 4.1.4 */
 
-#if USE_NOTMUCH
-#include "mutt_notmuch.h"
-#endif
-
 static int address_header_decode (char **str);
 static int copy_delete_attach (BODY *b, FILE *fpin, FILE *fpout, char *date);
 
@@ -721,7 +717,7 @@ _mutt_append_message (CONTEXT *dest, FILE *fpin, CONTEXT *src, HEADER *hdr,
   fseeko (fpin, hdr->offset, 0);
   if (fgets (buf, sizeof (buf), fpin) == NULL)
     return -1;
-  
+
   if ((msg = mx_open_new_message (dest, hdr, is_from (buf, NULL, 0, NULL) ? 0 : M_ADD_FROM)) == NULL)
     return -1;
   if (dest->magic == M_MBOX || dest->magic == M_MMDF)
@@ -731,16 +727,8 @@ _mutt_append_message (CONTEXT *dest, FILE *fpin, CONTEXT *src, HEADER *hdr,
   if (mx_commit_message (msg, dest) != 0)
     r = -1;
 
-#ifdef USE_NOTMUCH
-  if (r != -1 && src->magic == M_NOTMUCH) {
-       char old[_POSIX_PATH_MAX];
-
-       if (nm_header_get_fullpath(hdr, old, sizeof(old)))
-               nm_update_filename(src, old, msg->commited_path, hdr);
-  }
-#endif
-
   mx_close_message (&msg);
+
   return r;
 }
 
diff --git a/mh.c b/mh.c
index 48a419b4241149742383471b938f9ad3678b14bf..2f9f06e756c5ae3cab1ec54d10b38f21d45e081d 100644 (file)
--- a/mh.c
+++ b/mh.c
 #include <sys/time.h>
 #endif
 
+#ifdef USE_NOTMUCH
+#include "mutt_notmuch.h"
+#endif
+
 #define                INS_SORT_THRESHOLD              6
 
 struct maildir
@@ -1463,11 +1467,6 @@ int maildir_commit_message (CONTEXT * ctx, MESSAGE * msg, HEADER * hdr)
 
     if (safe_rename (msg->path, full) == 0)
     {
-      if (hdr)
-       mutt_str_replace (&hdr->path, path);
-      mutt_str_replace (&msg->commited_path, full);
-      FREE (&msg->path);
-
       /*
        * Adjust the mtime on the file to match the time at which this
        * message was received.  Currently this is only set when copying
@@ -1483,11 +1482,23 @@ int maildir_commit_message (CONTEXT * ctx, MESSAGE * msg, HEADER * hdr)
        if (utime (full, &ut))
        {
          mutt_perror (_("maildir_commit_message(): unable to set time on file"));
-         return -1;
+         goto post_rename_err;
        }
       }
 
+#ifdef USE_NOTMUCH
+      if (ctx->magic == M_NOTMUCH)
+       nm_update_filename(ctx, hdr->path, full, hdr);
+#endif
+      if (hdr)
+       mutt_str_replace (&hdr->path, path);
+      mutt_str_replace (&msg->commited_path, full);
+      FREE (&msg->path);
+
       return 0;
+
+post_rename_err:
+      return -1;
     }
     else if (errno != EEXIST)
     {
diff --git a/mx.c b/mx.c
index 631882faf05adec896adf36ef18f917fa87b5e35..bd8cceed063be5f847eedd7a2ef36c2ae7a28beb 100644 (file)
--- a/mx.c
+++ b/mx.c
 #include <ctype.h>
 #include <utime.h>
 
+#if USE_NOTMUCH
+#include "mutt_notmuch.h"
+#endif
+
 
 #define mutt_is_spool(s)  (mutt_strcmp (Spoolfile, s) == 0)
 
@@ -1582,6 +1586,9 @@ int mx_close_message (MESSAGE **msg)
   else
     (*msg)->fp = NULL;
 
+  dprint (2, (debugfile, "mx_close_message (): close: path=%s, commited=%s\n",
+       (*msg)->path, (*msg)->commited_path));
+
   if ((*msg)->path && (*msg)->magic != M_NOTMUCH)
   {
     dprint (1, (debugfile, "mx_close_message (): unlinking %s\n",