changeset 108:eb0659c9841e HEAD

when we figure out we should cache old body/bodystructure, use preparsed MessagePart from FIELD_TYPE_MESSAGEPART if it's already there.
author Timo Sirainen <tss@iki.fi>
date Mon, 02 Sep 2002 09:04:50 +0300
parents e2fe8921e8ad
children 27fd7817b226
files src/lib-index/mail-index-update.c
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-update.c	Mon Sep 02 05:39:42 2002 +0300
+++ b/src/lib-index/mail-index-update.c	Mon Sep 02 09:04:50 2002 +0300
@@ -403,9 +403,26 @@
 
 	if (IS_BODYSTRUCTURE_FIELD(cache_fields)) {
 		/* for body / bodystructure, we need need to
-		   fully parse the message */
+		   fully parse the message. unless it's already parsed
+		   and cached. */
 		pool = pool_create("index message parser", 2048, FALSE);
-		part = message_parse(pool, inbuf, update_header_func, &ctx);
+
+		value = update->index->lookup_field_raw(update->index,
+							update->rec,
+							FIELD_TYPE_MESSAGEPART,
+							&size);
+		if (value == NULL) {
+			part = message_parse(pool, inbuf,
+					     update_header_func, &ctx);
+		} else {
+			/* cached, construct the bodystructure using it.
+			   also we need to parse the header.. */
+			part = message_part_deserialize(pool, value, size);
+
+			io_buffer_seek(inbuf, 0);
+			message_parse_header(NULL, inbuf, NULL,
+					     update_header_func, &ctx);
+		}
 
 		/* update our sizes */
 		update->rec->header_size = part->header_size.physical_size;