#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);
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)
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;
}
#include <sys/time.h>
#endif
+#ifdef USE_NOTMUCH
+#include "mutt_notmuch.h"
+#endif
+
#define INS_SORT_THRESHOLD 6
struct maildir
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
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)
{
#include <ctype.h>
#include <utime.h>
+#if USE_NOTMUCH
+#include "mutt_notmuch.h"
+#endif
+
#define mutt_is_spool(s) (mutt_strcmp (Spoolfile, s) == 0)
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",