static int fs_sis_write_stream_finish(struct fs_file *_file, bool success) { struct sis_fs_file *file = (struct sis_fs_file *)_file; if (!success) { fs_write_stream_abort(file->super, &file->fs_output); fs_sis_file_copy_error(file); return -1; } if (file->hash_input != NULL && o_stream_cmp_equals(_file->output) && i_stream_is_eof(file->hash_input)) { if (fs_sis_try_link(file)) { fs_write_stream_abort(file->super, &file->fs_output); return 0; } } if (fs_write_stream_finish(file->super, &file->fs_output) < 0) { fs_sis_file_copy_error(file); return -1; } T_BEGIN { fs_sis_replace_hash_file(file); } T_END; return 0; }
static int fs_compress_write_stream_finish(struct fs_file *_file, bool success) { struct compress_fs_file *file = (struct compress_fs_file *)_file; struct istream *input; int ret; if (_file->output != NULL) { if (_file->output->closed) success = FALSE; if (_file->output == file->super_output) _file->output = NULL; else o_stream_unref(&_file->output); } if (!success) { if (file->temp_output != NULL) o_stream_destroy(&file->temp_output); if (file->super_output != NULL) fs_write_stream_abort(_file->parent, &file->super_output); return -1; } if (file->super_output != NULL) { i_assert(file->temp_output == NULL); return fs_write_stream_finish(_file->parent, &file->super_output); } if (file->temp_output == NULL) { /* finishing up */ i_assert(file->super_output == NULL); return fs_write_stream_finish(_file->parent, &file->temp_output); } /* finish writing the temporary file */ input = iostream_temp_finish(&file->temp_output, IO_BLOCK_SIZE); file->super_output = fs_write_stream(_file->parent); o_stream_nsend_istream(file->super_output, input); ret = fs_write_stream_finish(_file->parent, &file->super_output); i_stream_unref(&input); return ret; }