OP_RENAME_MAILBOX "rename the current mailbox (IMAP only)"
OP_REPLY "reply to a message"
OP_RESEND "use the current message as a template for a new one"
-OP_SAVE "save message/attachment to a file"
+OP_SAVE "save message/attachment to a mailbox/file"
OP_SEARCH "search for a regular expression"
OP_SEARCH_REVERSE "search backwards for a regular expression"
OP_SEARCH_NEXT "search for next match"
return (-1);
}
+/* 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 utimbuf utimebuf;
+ int i;
+ time_t now;
+
+ for (i = 0; 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;
+ }
+ }
+}
+
/* return values:
* 0 success
* -1 failure
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 utimbuf utimebuf;
struct m_update_t *newOffset = NULL;
struct m_update_t *oldOffset = NULL;
FILE *fp = NULL;
}
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 ();
return (-1);
}
- /* Restore the previous access/modification times */
- utimebuf.actime = statbuf.st_atime;
- utimebuf.modtime = statbuf.st_mtime;
- utime (ctx->path, &utimebuf);
-
/* reopen the mailbox in read-only mode */
if ((ctx->fp = fopen (ctx->path, "r")) == NULL)
{
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 */