{
struct istream *input;
off_t bytes;
+ int ret = 0;
input = i_stream_create_limit(file->input, count);
bytes = o_stream_send_istream(output, input);
- errno = input->stream_errno;
- i_stream_unref(&input);
- if (errno != 0) {
+ if (input->stream_errno != 0) {
mail_storage_set_critical(&file->storage->storage,
- "read(%s) failed: %m", file->cur_path);
- return -1;
- }
- if (o_stream_nfinish(output) < 0) {
+ "read(%s) failed: %s", file->cur_path,
+ i_stream_get_error(input));
+ ret = -1;
+ } else if (o_stream_nfinish(output) < 0) {
mail_storage_set_critical(&file->storage->storage,
- "write(%s) failed: %m", out_path);
- return -1;
- }
- i_assert(bytes >= 0);
- if ((uoff_t)bytes != count) {
+ "write(%s) failed: %s", out_path,
+ o_stream_get_error(output));
+ ret = -1;
+ } else if ((uoff_t)bytes != count) {
+ i_assert(bytes >= 0);
mail_storage_set_critical(&file->storage->storage,
"o_stream_send_istream(%s) copied only %"
PRIuUOFF_T" of %"PRIuUOFF_T" bytes",
out_path, bytes, count);
- return -1;
+ ret = -1;
}
- return 0;
+ i_stream_unref(&input);
+ return ret;
}
static void dbox_file_skip_broken_header(struct dbox_file *file)
ret = message_get_body_size(body_input, &body, &has_nuls);
i_stream_unref(&body_input);
if (ret < 0) {
- errno = body_input->stream_errno;
mail_storage_set_critical(&file->storage->storage,
- "read(%s) failed: %m", file->cur_path);
+ "read(%s) failed: %s", file->cur_path,
+ i_stream_get_error(body_input));
return -1;
}
}
if (o_stream_nfinish(output) < 0) {
mail_storage_set_critical(&file->storage->storage,
- "write(%s) failed: %m", temp_path);
+ "write(%s) failed: %s", temp_path, o_stream_get_error(output));
ret = -1;
}
return ret;
o_stream_cork(ctx->dbox_output);
if (o_stream_send(ctx->dbox_output, &dbox_msg_hdr,
sizeof(dbox_msg_hdr)) < 0) {
- mail_storage_set_critical(_storage, "write(%s) failed: %m",
- o_stream_get_name(ctx->dbox_output));
+ mail_storage_set_critical(_storage, "write(%s) failed: %s",
+ o_stream_get_name(ctx->dbox_output),
+ o_stream_get_error(ctx->dbox_output));
ctx->failed = TRUE;
}
_ctx->data.output = ctx->dbox_output;
}
if (o_stream_nfinish(mdata->output) < 0) {
mail_storage_set_critical(ctx->ctx.transaction->box->storage,
- "write(%s) failed: %m",
- o_stream_get_name(mdata->output));
+ "write(%s) failed: %s",
+ o_stream_get_name(mdata->output),
+ o_stream_get_error(mdata->output));
ctx->failed = TRUE;
}
if (mdata->output != dbox_output) {