dovecot-2.2: lib-storage: Set virtual/physical size in dest_mail...

dovecot at dovecot.org dovecot at dovecot.org
Thu Apr 18 17:54:41 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/f0b232b956a6
changeset: 16298:f0b232b956a6
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Apr 18 17:54:29 2013 +0300
description:
lib-storage: Set virtual/physical size in dest_mail when copying, if possible.
Ideally lib-index would be fixed so this wouldn't be necessary. The
lib-index way of fixing it would also be useful for more than just quota
plugin.

diffstat:

 src/lib-storage/index/index-storage.c |  17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diffs (27 lines):

diff -r 61e567c7fdd7 -r f0b232b956a6 src/lib-storage/index/index-storage.c
--- a/src/lib-storage/index/index-storage.c	Thu Apr 18 17:48:38 2013 +0300
+++ b/src/lib-storage/index/index-storage.c	Thu Apr 18 17:54:29 2013 +0300
@@ -795,6 +795,23 @@
 		if (mail_cache_lookup_field(src_mail->transaction->cache_view, buf,
 					    src_mail->seq, src_field_idx) <= 0)
 			buffer_set_used_size(buf, 0);
+		else if (ctx->dest_mail != NULL &&
+			 (strcmp(name, "size.physical") == 0 ||
+			  strcmp(name, "size.virtual") == 0)) {
+			/* FIXME: until mail_cache_lookup() can read unwritten
+			   cached data from buffer, we'll do this optimization
+			   to make quota plugin's work faster */
+			struct index_mail *imail =
+				(struct index_mail *)ctx->dest_mail;
+			uoff_t size;
+
+			i_assert(buf->used == sizeof(size));
+			memcpy(&size, buf->data, sizeof(size));
+			if (strcmp(name, "size.physical") == 0)
+				imail->data.physical_size = size;
+			else
+				imail->data.virtual_size = size;
+		}
 	}
 	if (buf->used > 0) {
 		mail_cache_add(dest_trans->cache_trans, dest_seq,


More information about the dovecot-cvs mailing list