]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mbox: When saving messages buffer the output until it's full, so if we die
authorTimo Sirainen <tss@iki.fi>
Mon, 26 May 2008 21:12:01 +0000 (00:12 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 26 May 2008 21:12:01 +0000 (00:12 +0300)
at the beginning we don't just leave a single From_-line.

--HG--
branch : HEAD

src/lib-storage/index/mbox/mbox-save.c

index 32c9b2dbae30415b28913aeeeee2531c2feed89a..4d3b9a078ab841b8bb3d9cc4056ed222bda9beb4 100644 (file)
@@ -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;
        }