]> granicus.if.org Git - neomutt/commitdiff
Backout experimental patch
authorRocco Rutte <pdmef@gmx.net>
Thu, 18 Jun 2009 12:56:54 +0000 (14:56 +0200)
committerRocco Rutte <pdmef@gmx.net>
Thu, 18 Jun 2009 12:56:54 +0000 (14:56 +0200)
mbox.c

diff --git a/mbox.c b/mbox.c
index 730ba2e0ed51de6b9e5ecda20ec7f837e67f9515..36d496c8048876acce460b36487a22104d0a7def 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -681,32 +681,22 @@ int mbox_check_mailbox (CONTEXT *ctx, int *index_hint)
 
 /* if mailbox has at least 1 new message, sets mtime > atime of mailbox
  * so buffy check reports new mail */
-static void reset_atime (CONTEXT *ctx, struct stat *st)
+static void reset_atime (CONTEXT *ctx)
 {
   struct utimbuf utimebuf;
-  int i, found = 0;
-  struct stat _st;
+  int i;
+  time_t now = time (NULL);
 
-  if (!st)
+  for (i = 0; i < ctx->msgcount; i++)
   {
-    if (stat (ctx->path, &_st) < 0)
+    if (!ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read && !ctx->hdrs[i]->old)
+    {
+      utimebuf.actime = now - 1;
+      utimebuf.modtime = now;
+      utime (ctx->path, &utimebuf);
       return;
-    st = &_st;
+    }
   }
-
-  utimebuf.actime = st->st_atime;
-  utimebuf.modtime = st->st_mtime;
-
-  for (i = 0; !found && i < ctx->msgcount; i++)
-    if (!ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read && !ctx->hdrs[i]->old)
-      found = 1;
-
-  if (found && utimebuf.actime >= utimebuf.modtime)
-    utimebuf.actime = utimebuf.modtime - 1;
-  else
-    utimebuf.actime = utimebuf.modtime;
-
-  utime (ctx->path, &utimebuf);
 }
 
 /* return values:
@@ -722,7 +712,6 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   int need_sort = 0; /* flag to resort mailbox if new mail arrives */
   int first = -1;      /* first message to be written */
   LOFF_T offset;       /* location in mailbox to write changed messages */
-  struct stat statbuf;
   struct m_update_t *newOffset = NULL;
   struct m_update_t *oldOffset = NULL;
   FILE *fp = NULL;
@@ -914,15 +903,6 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   }
   fp = NULL;
 
-  /* Save the state of this folder. */
-  if (stat (ctx->path, &statbuf) == -1)
-  {
-    mutt_perror (ctx->path);
-    mutt_sleep (5);
-    unlink (tempfile);
-    goto bail;
-  }
-
   if ((fp = fopen (tempfile, "r")) == NULL)
   {
     mutt_unblock_signals ();
@@ -992,9 +972,6 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
     return (-1);
   }
 
-  /* Restore the previous access/modification times */
-  reset_atime (ctx, &statbuf);
-
   /* reopen the mailbox in read-only mode */
   if ((ctx->fp = fopen (ctx->path, "r")) == NULL)
   {
@@ -1021,6 +998,11 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint)
   unlink (tempfile); /* remove partial copy of the mailbox */
   mutt_unblock_signals ();
 
+  /* if mailbox has new mail, mangle atime+mtime to make buffy check
+   * report new mail for it */
+  if (!option (OPTCHECKMBOXSIZE))
+    reset_atime (ctx);
+
   return (0); /* signal success */
 
 bail:  /* Come here in case of disaster */