From: Rocco Rutte Date: Tue, 12 May 2009 14:26:00 +0000 (+0200) Subject: Backout errorneously commited mbox atime fix X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=823f8c7c0bcfe819b9cc5bcd356881f62847dcc5;p=neomutt Backout errorneously commited mbox atime fix --- diff --git a/ChangeLog b/ChangeLog index 9d16d5a88..b18b645ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2009-05-12 15:21 +0200 Rocco Rutte (644cfc8070f7) + + * OPS, mbox.c: Fix description for + +2009-04-29 14:49 +0200 Rocco Rutte (335e6f782862) + + * ChangeLog, browser.c: Fix maildir times in mailboxes browser. Closes + #626. + + Instead of using the (pointless) mtime of the top-level maildir + folder, use the latest mtime of the "new" and "cur" subdirectories. + Maildir folders in the mailboxes list can now be properly sorted by + date. This does not affect the directory browser. Also see #2421. + 2009-04-29 11:53 +0200 Rocco Rutte (366d992abcb4) * mailbox.h, mh.c, mx.c: Move Maildir/MH folder detection from mx.c to diff --git a/mbox.c b/mbox.c index 60fbbdd37..844da877d 100644 --- a/mbox.c +++ b/mbox.c @@ -679,26 +679,6 @@ 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; - - 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 @@ -712,6 +692,8 @@ 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; @@ -903,6 +885,15 @@ 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 (); @@ -971,6 +962,11 @@ 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) { @@ -997,11 +993,6 @@ 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 */