dovecot: When status is returned, make sure we return correct ui...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 12 05:51:10 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/7aa61bb91ba3
changeset: 5961:7aa61bb91ba3
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 12 05:50:10 2007 +0300
description:
When status is returned, make sure we return correct uidvalidity/nextuid
values from uidlist if index isn't up-to-date.

diffstat:

1 file changed, 25 insertions(+), 1 deletion(-)
src/lib-storage/index/maildir/maildir-storage.c |   26 ++++++++++++++++++++++-

diffs (43 lines):

diff -r 33908f232e9a -r 7aa61bb91ba3 src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c	Thu Jul 12 04:56:02 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Thu Jul 12 05:50:10 2007 +0300
@@ -843,6 +843,30 @@ static int maildir_storage_mailbox_close
 	maildir_keywords_deinit(mbox->keywords);
 	maildir_uidlist_deinit(mbox->uidlist);
 	return index_storage_mailbox_close(box);
+}
+
+static int maildir_storage_get_status(struct mailbox *box,
+				      enum mailbox_status_items items,
+				      struct mailbox_status *status_r)
+{
+	struct maildir_mailbox *mbox = (struct maildir_mailbox *)box;
+	uint32_t uid_validity, next_uid;
+
+	if (index_storage_get_status(box, items, status_r) < 0)
+		return -1;
+
+	/* if index isn't up-to-date, get the values from uidlist */
+	if (maildir_uidlist_refresh(mbox->uidlist) < 0)
+		return -1;
+
+	uid_validity = maildir_uidlist_get_uid_validity(mbox->uidlist);
+	if (uid_validity != 0)
+		status_r->uidvalidity = uid_validity;
+
+	next_uid = maildir_uidlist_get_next_uid(mbox->uidlist);
+	if (status_r->uidnext < next_uid)
+		status_r->uidnext = next_uid;
+	return 0;
 }
 
 static void maildir_notify_changes(struct mailbox *box)
@@ -1030,7 +1054,7 @@ struct mailbox maildir_mailbox = {
 		index_storage_is_readonly,
 		index_storage_allow_new_keywords,
 		maildir_storage_mailbox_close,
-		index_storage_get_status,
+		maildir_storage_get_status,
 		maildir_storage_sync_init,
 		index_mailbox_sync_next,
 		index_mailbox_sync_deinit,


More information about the dovecot-cvs mailing list