dovecot-1.1: Maildir: If dovecot-uidlist has wrong cached virtua...

dovecot at dovecot.org dovecot at dovecot.org
Sun May 25 01:45:34 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/abdf9e06a956
changeset: 7538:abdf9e06a956
user:      Timo Sirainen <tss at iki.fi>
date:      Sun May 25 01:45:31 2008 +0300
description:
Maildir: If dovecot-uidlist has wrong cached virtual size, remove it when we
detect it. If maildir filename has wrong W value, log a clear error about it.

diffstat:

3 files changed, 34 insertions(+), 3 deletions(-)
src/lib-storage/index/maildir/maildir-mail.c    |   30 ++++++++++++++++++++++-
src/lib-storage/index/maildir/maildir-uidlist.c |    6 +++-
src/lib-storage/index/maildir/maildir-uidlist.h |    1 

diffs (73 lines):

diff -r d432ef4835e3 -r abdf9e06a956 src/lib-storage/index/maildir/maildir-mail.c
--- a/src/lib-storage/index/maildir/maildir-mail.c	Sun May 25 01:30:11 2008 +0300
+++ b/src/lib-storage/index/maildir/maildir-mail.c	Sun May 25 01:45:31 2008 +0300
@@ -462,6 +462,34 @@ static int maildir_mail_get_stream(struc
 	return index_mail_init_stream(mail, hdr_size, body_size, stream_r);
 }
 
+static void maildir_mail_set_cache_corrupted(struct mail *_mail,
+					     enum mail_fetch_field field)
+{
+	struct index_mail *mail = (struct index_mail *)_mail;
+	struct maildir_mailbox *mbox = (struct maildir_mailbox *)mail->ibox;
+	enum maildir_uidlist_rec_flag flags;
+	const char *fname;
+	uoff_t size;
+
+	if (field == MAIL_FETCH_VIRTUAL_SIZE) {
+		/* make sure it gets removed from uidlist.
+		   if it's in file name, we can't really do more than log it. */
+		fname = maildir_uidlist_lookup(mbox->uidlist,
+					       _mail->uid, &flags);
+		if (maildir_filename_get_size(fname, MAILDIR_EXTRA_VIRTUAL_SIZE,
+					      &size)) {
+			i_error("Maildir filename has wrong W value: %s/%s",
+				mbox->path, fname);
+		} else if (maildir_uidlist_lookup_ext(mbox->uidlist, _mail->uid,
+				MAILDIR_UIDLIST_REC_EXT_VSIZE) != NULL) {
+			maildir_uidlist_set_ext(mbox->uidlist, _mail->uid,
+						MAILDIR_UIDLIST_REC_EXT_VSIZE,
+						NULL);
+		}
+	}
+	index_mail_set_cache_corrupted(_mail, field);
+}
+
 struct mail_vfuncs maildir_mail_vfuncs = {
 	index_mail_close,
 	index_mail_free,
@@ -485,6 +513,6 @@ struct mail_vfuncs maildir_mail_vfuncs =
 	index_mail_update_flags,
 	index_mail_update_keywords,
 	index_mail_expunge,
-	index_mail_set_cache_corrupted,
+	maildir_mail_set_cache_corrupted,
 	index_mail_get_index_mail
 };
diff -r d432ef4835e3 -r abdf9e06a956 src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Sun May 25 01:30:11 2008 +0300
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Sun May 25 01:45:31 2008 +0300
@@ -935,8 +935,10 @@ maildir_uidlist_set_ext_real(struct mail
 			p += len;
 		}
 	}
-	buffer_append_c(buf, key);
-	buffer_append(buf, value, strlen(value) + 1);
+	if (value != NULL) {
+		buffer_append_c(buf, key);
+		buffer_append(buf, value, strlen(value) + 1);
+	}
 	buffer_append_c(buf, '\0');
 
 	rec->extensions = p_malloc(uidlist->record_pool, buf->used);
diff -r d432ef4835e3 -r abdf9e06a956 src/lib-storage/index/maildir/maildir-uidlist.h
--- a/src/lib-storage/index/maildir/maildir-uidlist.h	Sun May 25 01:30:11 2008 +0300
+++ b/src/lib-storage/index/maildir/maildir-uidlist.h	Sun May 25 01:45:31 2008 +0300
@@ -80,6 +80,7 @@ void maildir_uidlist_set_next_uid(struct
 void maildir_uidlist_set_next_uid(struct maildir_uidlist *uidlist,
 				  uint32_t next_uid, bool force);
 
+/* Update extended record. value=NULL removes the key. */
 void maildir_uidlist_set_ext(struct maildir_uidlist *uidlist, uint32_t uid,
 			     enum maildir_uidlist_rec_ext_key key,
 			     const char *value);


More information about the dovecot-cvs mailing list