From e43f08d55c689265ee56d0e7a44d54094f77f9ae Mon Sep 17 00:00:00 2001 From: Rocco Rutte Date: Sat, 11 Apr 2009 10:35:52 +0200 Subject: [PATCH] Don't raise new mail flag on mbox/mmdf Fcc mailboxes. Closes #1896. --- ChangeLog | 10 ++++++++++ buffy.c | 25 +++++++++++++++++++++++++ buffy.h | 4 ++++ commands.c | 23 +---------------------- sendlib.c | 10 +++++++++- 5 files changed, 49 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index ef920e6e..c1380c9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-04-08 16:25 +0200 Rocco Rutte (5b631ee33281) + + * hdrline.c: For %F, display Bcc recipient if no other recipients + found. Closes #3157. + +2009-04-08 15:46 +0200 Rocco Rutte (41786fbb344b) + + * ChangeLog, UPDATING, doc/manual.xml.head, doc/muttrc.man.head, + pattern.c: Make ~x match In-Reply-To, too. Closes #771. + 2009-04-07 19:57 +0200 Rocco Rutte (667b0006b586) * sendlib.c: Fix b5cbd0dab863, closes #3215. diff --git a/buffy.c b/buffy.c index f7b366cb..7b4d424c 100644 --- a/buffy.c +++ b/buffy.c @@ -134,6 +134,31 @@ static int test_new_folder (const char *path) return rc; } +void mutt_buffy_cleanup (const char *buf, struct stat *st) +{ + struct utimbuf ut; + BUFFY *tmp; + + if (option(OPTCHECKMBOXSIZE)) + { + tmp = mutt_find_mailbox (buf); + if (tmp && !tmp->new) + mutt_update_mailbox (tmp); + } + else + { + /* fix up the times so buffy won't get confused */ + if (st->st_mtime > st->st_atime) + { + ut.actime = st->st_atime; + ut.modtime = time (NULL); + utime (buf, &ut); + } + else + utime (buf, NULL); + } +} + BUFFY *mutt_find_mailbox (const char *path) { BUFFY *tmp = NULL; diff --git a/buffy.h b/buffy.h index 14f95172..7bf06d05 100644 --- a/buffy.h +++ b/buffy.h @@ -39,3 +39,7 @@ extern time_t BuffyDoneTime; /* last time we knew for sure how much mail there w BUFFY *mutt_find_mailbox (const char *path); void mutt_update_mailbox (BUFFY * b); + +/* fixes up atime + mtime after mbox/mmdf mailbox was modified + according to stat() info taken before a modification */ +void mutt_buffy_cleanup (const char *buf, struct stat *st); diff --git a/commands.c b/commands.c index 35707954..9aa505e7 100644 --- a/commands.c +++ b/commands.c @@ -706,8 +706,6 @@ int mutt_save_message (HEADER *h, int delete, char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX]; CONTEXT ctx; struct stat st; - BUFFY *tmp = NULL; - struct utimbuf ut; *redraw = 0; @@ -841,26 +839,7 @@ int mutt_save_message (HEADER *h, int delete, mx_close_mailbox (&ctx, NULL); if (need_buffy_cleanup) - { - if (option(OPTCHECKMBOXSIZE)) - { - tmp = mutt_find_mailbox (buf); - if (tmp && !tmp->new) - mutt_update_mailbox (tmp); - } - else - { - /* fix up the times so buffy won't get confused */ - if (st.st_mtime > st.st_atime) - { - ut.actime = st.st_atime; - ut.modtime = time (NULL); - utime (buf, &ut); - } - else - utime (buf, NULL); - } - } + mutt_buffy_cleanup (ctx.path, &st); mutt_clear_error (); return (0); diff --git a/sendlib.c b/sendlib.c index 8ba2cacf..25cab080 100644 --- a/sendlib.c +++ b/sendlib.c @@ -34,6 +34,7 @@ #include "charset.h" #include "mutt_crypt.h" #include "mutt_idna.h" +#include "buffy.h" #include #include @@ -2473,7 +2474,8 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post, MESSAGE *msg; char tempfile[_POSIX_PATH_MAX]; FILE *tempfp = NULL; - int r; + int r, need_buffy_cleanup = 0; + struct stat st; if (post) set_noconv_flags (hdr->content, 1); @@ -2497,6 +2499,9 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post, mx_close_mailbox (&f, NULL); return (-1); } + /* remember new mail status before appending message */ + need_buffy_cleanup = 1; + stat (path, &st); } hdr->read = !post; /* make sure to put it in the `cur' directory (maildir) */ @@ -2641,6 +2646,9 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int post, mx_close_message (&msg); mx_close_mailbox (&f, NULL); + if (!post && need_buffy_cleanup) + mutt_buffy_cleanup (path, &st); + if (post) set_noconv_flags (hdr->content, 0); -- 2.40.0