From: Timo Sirainen Date: Wed, 17 Jun 2015 09:21:52 +0000 (+0300) Subject: lib-fs: Call o_stream_nfinish() automatically for all backends in fs_write_stream_fin... X-Git-Tag: 2.2.19.rc1~321 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4244105be4eee427a90983d17070b438f6e2cdec;p=thirdparty%2Fdovecot%2Fcore.git lib-fs: Call o_stream_nfinish() automatically for all backends in fs_write_stream_finish() Otherwise each backend needs to do it internally. fs-metawrap for example was missing this and causing assert-crashes. --- diff --git a/src/lib-fs/fs-api.c b/src/lib-fs/fs-api.c index 88b355d3d0..f1b6965afa 100644 --- a/src/lib-fs/fs-api.c +++ b/src/lib-fs/fs-api.c @@ -557,14 +557,23 @@ struct ostream *fs_write_stream(struct fs_file *file) int fs_write_stream_finish(struct fs_file *file, struct ostream **output) { int ret; + bool success = TRUE; i_assert(*output == file->output || *output == NULL); *output = NULL; if (file->output != NULL) o_stream_uncork(file->output); + if (file->output != NULL) { + if (o_stream_nfinish(file->output) < 0) { + fs_set_error(file->fs, "write(%s) failed: %s", + o_stream_get_name(file->output), + o_stream_get_error(file->output)); + success = FALSE; + } + } T_BEGIN { - ret = file->fs->v.write_stream_finish(file, TRUE); + ret = file->fs->v.write_stream_finish(file, success); } T_END; if (ret != 0) file->metadata_changed = FALSE;