changeset 8061:7f1389badb4c HEAD

mbox: Saving may have truncated the mail being saved. save_continue() must not return if there's still data to be saved and index_mail_cache_parse_continue() may read more of it, so make sure after calling that the save input is handled.
author Timo Sirainen <tss@iki.fi>
date Mon, 04 Aug 2008 10:16:32 -0400
parents 4bfe7618743e
children a69c49565a5b
files src/lib-storage/index/mbox/mbox-save.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-save.c	Mon Aug 04 01:41:39 2008 +0300
+++ b/src/lib-storage/index/mbox/mbox-save.c	Mon Aug 04 10:16:32 2008 -0400
@@ -577,11 +577,9 @@
 		return mbox_save_body(ctx);
 	}
 
-	while ((ret = i_stream_read(ctx->input)) != -1) {
+	while ((ret = i_stream_read(ctx->input)) > 0) {
 		if (ctx->mail != NULL)
 			index_mail_cache_parse_continue(ctx->mail);
-		if (ret == 0)
-			return 0;
 
 		data = i_stream_get_data(ctx->input, &size);
 		for (i = 0; i < size; i++) {
@@ -608,6 +606,8 @@
 		ctx->last_char = data[size-1];
 		i_stream_skip(ctx->input, size);
 	}
+	if (ret == 0)
+		return 0;
 
 	if (ctx->last_char != '\n') {
 		if (o_stream_send(ctx->output, "\n", 1) < 0)