1 upstream test patch to fix the atime issue
2 (See #533439 and upstream #3271)
8 /* if mailbox has at least 1 new message, sets mtime > atime of mailbox
9 * so buffy check reports new mail */
10 -static void reset_atime (CONTEXT *ctx)
11 +static void reset_atime (CONTEXT *ctx, struct stat *st)
13 struct utimbuf utimebuf;
15 - time_t now = time (NULL);
19 - for (i = 0; i < ctx->msgcount; i++)
22 - if (!ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read && !ctx->hdrs[i]->old)
24 - utimebuf.actime = now - 1;
25 - utimebuf.modtime = now;
26 - utime (ctx->path, &utimebuf);
27 + if (stat (ctx->path, &_st) < 0)
33 + utimebuf.actime = st->st_atime;
34 + utimebuf.modtime = st->st_mtime;
36 + for (i = 0; !found && i < ctx->msgcount; i++)
37 + if (!ctx->hdrs[i]->deleted && !ctx->hdrs[i]->read && !ctx->hdrs[i]->old)
40 + if (found && utimebuf.actime >= utimebuf.modtime)
41 + utimebuf.actime = utimebuf.modtime - 1;
43 + utime (ctx->path, &utimebuf);
48 int need_sort = 0; /* flag to resort mailbox if new mail arrives */
49 int first = -1; /* first message to be written */
50 LOFF_T offset; /* location in mailbox to write changed messages */
51 + struct stat statbuf;
52 struct m_update_t *newOffset = NULL;
53 struct m_update_t *oldOffset = NULL;
59 + /* Save the state of this folder. */
60 + if (stat (ctx->path, &statbuf) == -1)
62 + mutt_perror (ctx->path);
68 if ((fp = fopen (tempfile, "r")) == NULL)
70 mutt_unblock_signals ();
75 + /* Restore the previous access/modification times */
76 + reset_atime (ctx, &statbuf);
78 /* reopen the mailbox in read-only mode */
79 if ((ctx->fp = fopen (ctx->path, "r")) == NULL)
81 @@ -1002,11 +1023,6 @@
82 unlink (tempfile); /* remove partial copy of the mailbox */
83 mutt_unblock_signals ();
85 - /* if mailbox has new mail, mangle atime+mtime to make buffy check
86 - * report new mail for it */
87 - if (!option (OPTCHECKMBOXSIZE))
90 return (0); /* signal success */
92 bail: /* Come here in case of disaster */