From: Karel Zak Date: Wed, 9 May 2012 07:44:13 +0000 (+0200) Subject: don't rename in DB before mx commit X-Git-Tag: neomutt-20160404~13^2~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4d79e89b203c9d8cc5aadd523490c56dff37e625;p=neomutt don't rename in DB before mx commit Signed-off-by: Karel Zak --- diff --git a/copy.c b/copy.c index 6ce6fc10f..e5610c28e 100644 --- a/copy.c +++ b/copy.c @@ -35,10 +35,6 @@ #include #include /* 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 48a419b42..2f9f06e75 100644 --- a/mh.c +++ b/mh.c @@ -56,6 +56,10 @@ #include #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 631882faf..bd8cceed0 100644 --- a/mx.c +++ b/mx.c @@ -64,6 +64,10 @@ #include #include +#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",