changeset 7559:dd9d344ba140 HEAD

mbox: When saving messages buffer the output until it's full, so if we die at the beginning we don't just leave a single From_-line.
author Timo Sirainen <tss@iki.fi>
date Tue, 27 May 2008 00:12:01 +0300
parents a1ba58f7d695
children fedeb23a3d53
files src/lib-storage/index/mbox/mbox-save.c
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/mbox/mbox-save.c	Mon May 26 18:50:58 2008 +0300
+++ b/src/lib-storage/index/mbox/mbox-save.c	Tue May 27 00:12:01 2008 +0300
@@ -328,6 +328,7 @@
 		ctx->output = o_stream_create_fd_file(mbox->mbox_fd,
 						      ctx->append_offset,
 						      FALSE);
+		o_stream_cork(ctx->output);
 	}
 	return 0;
 }
@@ -670,8 +671,10 @@
 
 	if (ctx->failed && ctx->mail_offset != (uoff_t)-1) {
 		/* saving this mail failed - truncate back to beginning of it */
+		(void)o_stream_flush(ctx->output);
 		if (ftruncate(ctx->mbox->mbox_fd, (off_t)ctx->mail_offset) < 0)
 			mbox_set_syscall_error(ctx->mbox, "ftruncate()");
+		o_stream_seek(ctx->output, ctx->mail_offset);
 		ctx->mail_offset = (uoff_t)-1;
 	}