]> granicus.if.org Git - mutt/commitdiff
The maildir_time patch.
authorMichael Elkins <me@sigpipe.org>
Tue, 12 Nov 2002 07:53:09 +0000 (07:53 +0000)
committerMichael Elkins <me@sigpipe.org>
Tue, 12 Nov 2002 07:53:09 +0000 (07:53 +0000)
mailbox.h
mh.c
mx.c

index 1f125716084a5fb33a4bd46454ac28ad0b44b3bc..afd743ea6cceaff882c9897b1d571d898d6ae874 100644 (file)
--- 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 dab356f021573d33f2238eb520d6fcba6ddcd173..359f3652e07b72162d52eb97c9ec541f7eebf612 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -40,6 +40,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <string.h>
+#include <utime.h>
 
 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 fd689b513577bcf80f302ef156f596018f353207..716a5a439d84285f651acefbf2c830e756c5e7f9 100644 (file)
--- 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