From: Rocco Rutte Date: Sat, 30 May 2009 17:37:33 +0000 (+0200) Subject: Keep new mail flag for mbox/mmdf folders after closing. Closes #1362. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2795a30906e4af1b7b83fc2dda3e67ab43e37ee5;p=neomutt Keep new mail flag for mbox/mmdf folders after closing. Closes #1362. --- diff --git a/ChangeLog b/ChangeLog index 395ff6768..99c06582a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-05-30 10:23 -0700 Vincent Lefevre (be7b3d349725) + + * po/fr.po: Updated French translation. + +2009-05-30 00:24 +0200 Rocco Rutte (f65a1eb8abce) + + * ChangeLog, smtp.c: Fix logic in f260f5836284 + 2009-05-29 21:33 +0200 Rocco Rutte (c4d86d4ea260) * pager.c: Drop modified version of and use mutt_read_line() in pager, diff --git a/mbox.c b/mbox.c index 06fdea998..db2cda639 100644 --- a/mbox.c +++ b/mbox.c @@ -679,6 +679,26 @@ int mbox_check_mailbox (CONTEXT *ctx, int *index_hint) 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 = time (NULL); + + 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 @@ -692,8 +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 utimbuf utimebuf; struct m_update_t *newOffset = NULL; struct m_update_t *oldOffset = NULL; FILE *fp = NULL; @@ -885,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 (); @@ -962,11 +971,6 @@ int mbox_sync_mailbox (CONTEXT *ctx, int *index_hint) 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) { @@ -993,6 +997,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 */