dovecot-2.2: lib-storage: Message size/sent date could have been...

dovecot at dovecot.org dovecot at dovecot.org
Thu Sep 13 17:13:12 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/460db6251639
changeset: 15044:460db6251639
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Sep 13 17:12:59 2012 +0300
description:
lib-storage: Message size/sent date could have been set as 0 in some cases.
It doesn't look like it ever happened with the current storage backends or
use cases.

diffstat:

 src/lib-storage/index/index-mail.c |  25 ++++++++++++++++---------
 1 files changed, 16 insertions(+), 9 deletions(-)

diffs (62 lines):

diff -r 7343ccbdd985 -r 460db6251639 src/lib-storage/index/index-mail.c
--- a/src/lib-storage/index/index-mail.c	Thu Sep 13 12:01:08 2012 +0300
+++ b/src/lib-storage/index/index-mail.c	Thu Sep 13 17:12:59 2012 +0300
@@ -330,6 +330,7 @@
 {
 	struct index_mail *mail = (struct index_mail *)_mail;
 	struct index_mail_data *data = &mail->data;
+	struct mail_sent_date sentdate;
 
 	data->cache_fetch_fields |= MAIL_FETCH_DATE;
 	if (data->sent_date.time != (uint32_t)-1) {
@@ -338,9 +339,9 @@
 		return 0;
 	}
 
-	(void)index_mail_get_fixed_field(mail, MAIL_CACHE_SENT_DATE,
-					 &data->sent_date,
-					 sizeof(data->sent_date));
+	if (index_mail_get_fixed_field(mail, MAIL_CACHE_SENT_DATE,
+				       &sentdate, sizeof(sentdate)))
+		data->sent_date = sentdate;
 
 	if (index_mail_cache_sent_date(mail) < 0)
 		return -1;
@@ -374,12 +375,15 @@
 bool index_mail_get_cached_virtual_size(struct index_mail *mail, uoff_t *size_r)
 {
 	struct index_mail_data *data = &mail->data;
+	uoff_t size;
 
 	data->cache_fetch_fields |= MAIL_FETCH_VIRTUAL_SIZE;
 	if (data->virtual_size == (uoff_t)-1) {
-		if (!index_mail_get_cached_uoff_t(mail,
-						  MAIL_CACHE_VIRTUAL_FULL_SIZE,
-						  &data->virtual_size)) {
+		if (index_mail_get_cached_uoff_t(mail,
+						 MAIL_CACHE_VIRTUAL_FULL_SIZE,
+						 &size))
+			data->virtual_size = size;
+		else {
 			if (!get_cached_msgpart_sizes(mail))
 				return FALSE;
 		}
@@ -442,12 +446,15 @@
 {
 	struct index_mail *mail = (struct index_mail *)_mail;
 	struct index_mail_data *data = &mail->data;
+	uoff_t size;
 
 	data->cache_fetch_fields |= MAIL_FETCH_PHYSICAL_SIZE;
 	if (data->physical_size == (uoff_t)-1) {
-		if (!index_mail_get_cached_uoff_t(mail,
-						  MAIL_CACHE_PHYSICAL_FULL_SIZE,
-						  &data->physical_size))
+		if (index_mail_get_cached_uoff_t(mail,
+						 MAIL_CACHE_PHYSICAL_FULL_SIZE,
+						 &size))
+			data->physical_size = size;
+		else
 			(void)get_cached_msgpart_sizes(mail);
 	}
 	*size_r = data->physical_size;


More information about the dovecot-cvs mailing list