Mercurial > dovecot > core-2.2
changeset 13549:b3111bbbaf22
maildir: Improved guessing filename when it's still in new/ dir.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 23 Sep 2011 14:52:46 +0300 |
parents | f24550491039 |
children | fecd095394b6 |
files | src/lib-storage/index/maildir/maildir-util.c |
diffstat | 1 files changed, 20 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-util.c Fri Sep 23 14:38:24 2011 +0300 +++ b/src/lib-storage/index/maildir/maildir-util.c Fri Sep 23 14:52:46 2011 +0300 @@ -23,13 +23,16 @@ static const char * maildir_filename_guess(struct maildir_mailbox *mbox, uint32_t uid, - const char *fname, bool *have_flags_r) + const char *fname, + enum maildir_uidlist_rec_flag *uidlist_flags, + bool *have_flags_r) { struct mail_index_view *view = mbox->flags_view; struct maildir_keywords_sync_ctx *kw_ctx; enum mail_flags flags; ARRAY_TYPE(keyword_indexes) keywords; + const char *p; uint32_t seq; if (view == NULL || !mail_index_lookup_seq(view, uid, &seq)) { @@ -50,6 +53,20 @@ flags, &keywords); maildir_keywords_sync_deinit(&kw_ctx); } + + if (*have_flags_r) { + /* don't even bother looking into new/ dir */ + *uidlist_flags &= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR; + } else if ((*uidlist_flags & MAILDIR_UIDLIST_REC_FLAG_MOVED) == 0 && + ((*uidlist_flags & MAILDIR_UIDLIST_REC_FLAG_NEW_DIR) != 0 || + index_mailbox_is_recent(&mbox->box, uid))) { + /* probably in new/ dir, drop ":2," from fname */ + *uidlist_flags |= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR; + p = strrchr(fname, MAILDIR_INFO_SEP); + if (p != NULL) + fname = t_strdup_until(fname, p); + } + return fname; } @@ -67,11 +84,8 @@ if ((flags & MAILDIR_UIDLIST_REC_FLAG_NONSYNCED) != 0) { /* let's see if we can guess the filename based on index */ - fname = maildir_filename_guess(mbox, uid, fname, &have_flags); - if (have_flags) { - /* don't even bother looking into new/ dir */ - flags &= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR; - } + fname = maildir_filename_guess(mbox, uid, fname, + &flags, &have_flags); } if ((flags & MAILDIR_UIDLIST_REC_FLAG_NEW_DIR) != 0) {