Mercurial > dovecot > original-hg > dovecot-1.2
diff src/lib-storage/index/maildir/maildir-sync.c @ 6037:d911d943438e HEAD
Recent flag handling rewrite. Still not perfect with maildir.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 16 Jul 2007 09:48:02 +0300 |
parents | 3b260c6d9207 |
children | 913b188f4dd4 |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-sync.c Mon Jul 16 07:52:50 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-sync.c Mon Jul 16 09:48:02 2007 +0300 @@ -453,16 +453,15 @@ /* someone else moved it already */ dir_changed = TRUE; move_count++; - flags |= MAILDIR_UIDLIST_REC_FLAG_MOVED; + flags |= MAILDIR_UIDLIST_REC_FLAG_MOVED | + MAILDIR_UIDLIST_REC_FLAG_RECENT; } else if (ENOSPACE(errno) || errno == EACCES) { /* not enough disk space / read-only maildir, leave here */ - flags |= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR | - MAILDIR_UIDLIST_REC_FLAG_RECENT; + flags |= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR; move_new = FALSE; } else { - flags |= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR | - MAILDIR_UIDLIST_REC_FLAG_RECENT; + flags |= MAILDIR_UIDLIST_REC_FLAG_NEW_DIR; mail_storage_set_critical(storage, "rename(%s, %s) failed: %m", str_c(src), str_c(dest)); @@ -645,6 +644,22 @@ } } +static bool move_recent_messages(struct maildir_sync_context *ctx) +{ + const struct mail_index_header *hdr; + + if (ctx->mbox->ibox.keep_recent) + return FALSE; + + (void)maildir_uidlist_refresh(ctx->mbox->uidlist); + + /* if there are files in new/, we'll need to move them. we'll check + this by checking if we have any recent messages */ + hdr = mail_index_get_header(ctx->mbox->ibox.view); + return hdr->first_recent_uid < + maildir_uidlist_get_next_uid(ctx->mbox->uidlist); +} + static int maildir_sync_context(struct maildir_sync_context *ctx, bool forced, bool sync_last_commit) { @@ -659,8 +674,11 @@ &new_changed, &cur_changed) < 0) return -1; - if (!new_changed && !cur_changed) - return 1; + if (!new_changed && !cur_changed) { + if (!move_recent_messages(ctx)) + return 1; + new_changed = TRUE; + } } else { new_changed = cur_changed = TRUE; }