dovecot-1.1: mbox: When saving messages buffer the output until ...

dovecot at dovecot.org dovecot at dovecot.org
Tue May 27 00:12:06 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/dd9d344ba140
changeset: 7559:dd9d344ba140
user:      Timo Sirainen <tss at iki.fi>
date:      Tue May 27 00:12:01 2008 +0300
description:
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.

diffstat:

1 file changed, 3 insertions(+)
src/lib-storage/index/mbox/mbox-save.c |    3 +++

diffs (22 lines):

diff -r a1ba58f7d695 -r dd9d344ba140 src/lib-storage/index/mbox/mbox-save.c
--- 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 @@ mbox_save_init_file(struct mbox_save_con
 		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 @@ int mbox_save_finish(struct mail_save_co
 
 	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;
 	}
 


More information about the dovecot-cvs mailing list