From: Michael Elkins Date: Tue, 12 Nov 2002 07:53:09 +0000 (+0000) Subject: The maildir_time patch. X-Git-Tag: mutt-1-5-2-rel~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cf29e482598ee41a37bfc7db6f72540447552504;p=mutt The maildir_time patch. --- diff --git a/mailbox.h b/mailbox.h index 1f125716..afd743ea 100644 --- a/mailbox.h +++ b/mailbox.h @@ -51,6 +51,7 @@ typedef struct unsigned flagged : 1; unsigned replied : 1; } flags; + time_t received; /* the time at which this message was received */ } MESSAGE; CONTEXT *mx_open_mailbox (const char *, int, CONTEXT *); diff --git a/mh.c b/mh.c index dab356f0..359f3652 100644 --- a/mh.c +++ b/mh.c @@ -40,6 +40,7 @@ #include #include #include +#include struct maildir { @@ -1000,6 +1001,26 @@ int maildir_commit_message (CONTEXT * ctx, MESSAGE * msg, HEADER * hdr) if (hdr) mutt_str_replace (&hdr->path, path); 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 + * messages between mailboxes, so we test to ensure that it is + * actually set. + */ + if (msg->received) + { + struct utimbuf ut; + + ut.actime = msg->received; + ut.modtime = msg->received; + if (utime (full, &ut)) + { + mutt_perror (_("maildir_commit_message(): unable to set time on file")); + return -1; + } + } + return 0; } else if (errno != EEXIST) diff --git a/mx.c b/mx.c index fd689b51..716a5a43 100644 --- a/mx.c +++ b/mx.c @@ -1254,7 +1254,6 @@ MESSAGE *mx_open_new_message (CONTEXT *dest, HEADER *hdr, int flags) MESSAGE *msg; int (*func) (MESSAGE *, CONTEXT *, HEADER *); ADDRESS *p = NULL; - time_t t; switch (dest->magic) { @@ -1288,7 +1287,11 @@ MESSAGE *mx_open_new_message (CONTEXT *dest, HEADER *hdr, int flags) msg->flags.flagged = hdr->flagged; msg->flags.replied = hdr->replied; msg->flags.read = hdr->read; + msg->received = hdr->received; } + + if(msg->received == 0) + time(&msg->received); if (func (msg, dest, hdr) == 0) { @@ -1306,15 +1309,9 @@ MESSAGE *mx_open_new_message (CONTEXT *dest, HEADER *hdr, int flags) p = hdr->env->sender; else p = hdr->env->from; - - if (!hdr->received) - hdr->received = time (NULL); - t = hdr->received; } - else - t = time (NULL); - fprintf (msg->fp, "From %s %s", p ? p->mailbox : NONULL(Username), ctime (&t)); + fprintf (msg->fp, "From %s %s", p ? p->mailbox : NONULL(Username), ctime (&msg->received)); } } else