dovecot-1.2: maildir: Save cur/ mtime to index after moving save...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Sep 10 21:09:28 EEST 2009
details: http://hg.dovecot.org/dovecot-1.2/rev/f2a6a99ff9ea
changeset: 9376:f2a6a99ff9ea
user: Timo Sirainen <tss at iki.fi>
date: Thu Sep 10 14:09:23 2009 -0400
description:
maildir: Save cur/ mtime to index after moving saved messages there, not before.
diffstat:
1 file changed, 14 insertions(+), 7 deletions(-)
src/lib-storage/index/maildir/maildir-sync-index.c | 21 +++++++++++++-------
diffs (52 lines):
diff -r fcb34048a29c -r f2a6a99ff9ea src/lib-storage/index/maildir/maildir-sync-index.c
--- a/src/lib-storage/index/maildir/maildir-sync-index.c Thu Sep 10 13:57:26 2009 -0400
+++ b/src/lib-storage/index/maildir/maildir-sync-index.c Thu Sep 10 14:09:23 2009 -0400
@@ -29,6 +29,7 @@ struct maildir_index_sync_context {
ARRAY_TYPE(keyword_indexes) keywords, idx_keywords;
uint32_t seq, uid;
+ bool update_maildir_hdr_cur;
};
struct maildir_keywords_sync_ctx *
@@ -227,6 +228,15 @@ maildir_sync_index_update_ext_header(str
struct maildir_mailbox *mbox = ctx->mbox;
const void *data;
size_t data_size;
+ struct stat st;
+
+ if (ctx->update_maildir_hdr_cur &&
+ stat(t_strconcat(mbox->path, "/cur", NULL), &st) == 0) {
+ if ((time_t)mbox->maildir_hdr.cur_check_time < st.st_mtime)
+ mbox->maildir_hdr.cur_check_time = st.st_mtime;
+ mbox->maildir_hdr.cur_mtime = st.st_mtime;
+ mbox->maildir_hdr.cur_mtime_nsecs = ST_MTIME_NSEC(st);
+ }
mail_index_get_header_ext(mbox->ibox.view, mbox->maildir_ext_id,
&data, &data_size);
@@ -384,7 +394,6 @@ int maildir_sync_index(struct maildir_in
unsigned int changes = 0;
int ret = 0;
time_t time_before_sync;
- struct stat st;
bool expunged, full_rescan = FALSE;
i_assert(!mbox->syncing_commit);
@@ -559,12 +568,10 @@ int maildir_sync_index(struct maildir_in
if (mbox->ibox.box.v.sync_notify != NULL)
mbox->ibox.box.v.sync_notify(&mbox->ibox.box, 0, 0);
- if (stat(t_strconcat(mbox->path, "/cur", NULL), &st) == 0) {
- mbox->maildir_hdr.new_check_time =
- I_MAX(st.st_mtime, time_before_sync);
- mbox->maildir_hdr.cur_mtime = st.st_mtime;
- mbox->maildir_hdr.cur_mtime_nsecs = ST_MTIME_NSEC(st);
- }
+ /* check cur/ mtime later. if we came here from saving messages they
+ could still be moved to cur/ directory. */
+ ctx->update_maildir_hdr_cur = TRUE;
+ mbox->maildir_hdr.cur_check_time = time_before_sync;
if (uid_validity == 0) {
uid_validity = hdr->uid_validity != 0 ? hdr->uid_validity :
More information about the dovecot-cvs
mailing list