From: Timo Sirainen Date: Mon, 26 May 2008 21:12:01 +0000 (+0300) Subject: mbox: When saving messages buffer the output until it's full, so if we die X-Git-Tag: 1.1.rc6~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b643f5f3369eb7db818bbef5df635d642d4f3606;p=thirdparty%2Fdovecot%2Fcore.git 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. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/mbox/mbox-save.c b/src/lib-storage/index/mbox/mbox-save.c index 32c9b2dbae..4d3b9a078a 100644 --- a/src/lib-storage/index/mbox/mbox-save.c +++ b/src/lib-storage/index/mbox/mbox-save.c @@ -328,6 +328,7 @@ mbox_save_init_file(struct mbox_save_context *ctx, 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_context *_ctx) 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; }