upstream test patch to fix the atime issue
(See #533439 and upstream #3271)
-diff --git a/mbox.c b/mbox.c
--- a/mbox.c
+++ b/mbox.c
-@@ -681,22 +681,32 @@ int mbox_check_mailbox (CONTEXT *ctx, in
+@@ -685,22 +685,30 @@
/* if mailbox has at least 1 new message, sets mtime > atime of mailbox
* so buffy check reports new mail */
- for (i = 0; i < ctx->msgcount; i++)
+ if (!st)
{
+- if (!ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read && !ctx->hdrs[i]->old)
+- {
+- utimebuf.actime = now - 1;
+- utimebuf.modtime = now;
+- utime (ctx->path, &utimebuf);
+ if (stat (ctx->path, &_st) < 0)
-+ return;
+ 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)
-- {
-- utimebuf.actime = now - 1;
-- utimebuf.modtime = now;
-- utime (ctx->path, &utimebuf);
-- return;
-- }
-- }
++ 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:
-@@ -712,6 +722,7 @@ int mbox_sync_mailbox (CONTEXT *ctx, int
+@@ -716,6 +724,7 @@
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 m_update_t *newOffset = NULL;
struct m_update_t *oldOffset = NULL;
FILE *fp = NULL;
-@@ -903,6 +914,15 @@ int mbox_sync_mailbox (CONTEXT *ctx, int
+@@ -907,6 +916,15 @@
}
fp = NULL;
if ((fp = fopen (tempfile, "r")) == NULL)
{
mutt_unblock_signals ();
-@@ -972,6 +992,9 @@ int mbox_sync_mailbox (CONTEXT *ctx, int
+@@ -976,6 +994,9 @@
return (-1);
}
/* reopen the mailbox in read-only mode */
if ((ctx->fp = fopen (ctx->path, "r")) == NULL)
{
-@@ -998,11 +1021,6 @@ int mbox_sync_mailbox (CONTEXT *ctx, int
+@@ -1002,11 +1023,6 @@
unlink (tempfile); /* remove partial copy of the mailbox */
mutt_unblock_signals ();