{
struct mail_storage *storage = &ctx->file->storage->storage;
- if (ctx->last_flush_offset == ctx->output->offset)
+ if (ctx->last_flush_offset == ctx->output->offset &&
+ ctx->last_checkpoint_offset == ctx->output->offset)
return 0;
if (o_stream_flush(ctx->output) < 0) {
return -1;
}
+ if (ctx->last_checkpoint_offset != ctx->output->offset) {
+ if (ftruncate(ctx->file->fd, ctx->last_checkpoint_offset) < 0) {
+ dbox_file_set_syscall_error(ctx->file, "ftruncate()");
+ return -1;
+ }
+ o_stream_seek(ctx->output, ctx->last_checkpoint_offset);
+ }
+
if (storage->set->parsed_fsync_mode != FSYNC_MODE_NEVER) {
if (fdatasync(ctx->file->fd) < 0) {
dbox_file_set_syscall_error(ctx->file, "fdatasync()");