dovecot-1.2: Maildir and Cydir: When saving mail, expose ostream...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Mar 10 03:52:47 EET 2009
details: http://hg.dovecot.org/dovecot-1.2/rev/a05a7a73b475
changeset: 8808:a05a7a73b475
user: Timo Sirainen <tss at iki.fi>
date: Mon Mar 09 21:52:42 2009 -0400
description:
Maildir and Cydir: When saving mail, expose ostream to mail_save_context.output.
This would allow plugins to hook into it.
diffstat:
3 files changed, 15 insertions(+), 16 deletions(-)
src/lib-storage/index/cydir/cydir-save.c | 11 +++++------
src/lib-storage/index/maildir/maildir-save.c | 19 +++++++++----------
src/lib-storage/mail-storage-private.h | 1 +
diffs (137 lines):
diff -r 2a3fd0d46bc6 -r a05a7a73b475 src/lib-storage/index/cydir/cydir-save.c
--- a/src/lib-storage/index/cydir/cydir-save.c Mon Mar 09 21:00:48 2009 -0400
+++ b/src/lib-storage/index/cydir/cydir-save.c Mon Mar 09 21:52:42 2009 -0400
@@ -27,7 +27,6 @@ struct cydir_save_context {
/* updated for each appended mail: */
uint32_t seq;
struct istream *input;
- struct ostream *output;
struct mail *mail;
int fd;
@@ -90,9 +89,9 @@ int cydir_save_begin(struct mail_save_co
path = cydir_get_save_path(ctx, ctx->mail_count);
ctx->fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0660);
if (ctx->fd != -1) {
- ctx->output =
+ _ctx->output =
o_stream_create_fd_file(ctx->fd, 0, FALSE);
- o_stream_cork(ctx->output);
+ o_stream_cork(_ctx->output);
} else {
mail_storage_set_critical(trans->box->storage,
"open(%s) failed: %m", path);
@@ -134,7 +133,7 @@ int cydir_save_continue(struct mail_save
return -1;
do {
- if (o_stream_send_istream(ctx->output, ctx->input) < 0) {
+ if (o_stream_send_istream(_ctx->output, ctx->input) < 0) {
if (!mail_storage_set_error_from_errno(storage)) {
mail_storage_set_critical(storage,
"o_stream_send_istream(%s) failed: %m",
@@ -161,7 +160,7 @@ int cydir_save_finish(struct mail_save_c
ctx->finished = TRUE;
- if (o_stream_flush(ctx->output) < 0) {
+ if (o_stream_flush(_ctx->output) < 0) {
mail_storage_set_critical(storage,
"o_stream_flush(%s) failed: %m", path);
ctx->failed = TRUE;
@@ -195,7 +194,7 @@ int cydir_save_finish(struct mail_save_c
}
}
- o_stream_destroy(&ctx->output);
+ o_stream_destroy(&_ctx->output);
if (close(ctx->fd) < 0) {
mail_storage_set_critical(storage,
"close(%s) failed: %m", path);
diff -r 2a3fd0d46bc6 -r a05a7a73b475 src/lib-storage/index/maildir/maildir-save.c
--- a/src/lib-storage/index/maildir/maildir-save.c Mon Mar 09 21:00:48 2009 -0400
+++ b/src/lib-storage/index/maildir/maildir-save.c Mon Mar 09 21:52:42 2009 -0400
@@ -52,7 +52,6 @@ struct maildir_save_context {
ARRAY_TYPE(keyword_indexes) keywords_array;
struct istream *input;
- struct ostream *output;
int fd;
uint32_t first_seq, seq;
@@ -389,8 +388,8 @@ int maildir_save_begin(struct mail_save_
} T_END;
if (!ctx->failed) {
- ctx->output = o_stream_create_fd_file(ctx->fd, 0, FALSE);
- o_stream_cork(ctx->output);
+ _ctx->output = o_stream_create_fd_file(ctx->fd, 0, FALSE);
+ o_stream_cork(_ctx->output);
}
return ctx->failed ? -1 : 0;
}
@@ -404,7 +403,7 @@ int maildir_save_continue(struct mail_sa
return -1;
do {
- if (o_stream_send_istream(ctx->output, ctx->input) < 0) {
+ if (o_stream_send_istream(_ctx->output, ctx->input) < 0) {
if (!mail_storage_set_error_from_errno(storage)) {
mail_storage_set_critical(storage,
"o_stream_send_istream(%s/%s) "
@@ -440,7 +439,7 @@ static int maildir_save_finish_real(stru
}
path = t_strconcat(ctx->tmpdir, "/", ctx->file_last->basename, NULL);
- if (o_stream_flush(ctx->output) < 0) {
+ if (o_stream_flush(_ctx->output) < 0) {
if (!mail_storage_set_error_from_errno(storage)) {
mail_storage_set_critical(storage,
"o_stream_flush(%s) failed: %m", path);
@@ -485,14 +484,14 @@ static int maildir_save_finish_real(stru
i_stream_unref(&ctx->input);
/* remember the size in case we want to add it to filename */
- ctx->file_last->size = ctx->output->offset;
+ ctx->file_last->size = _ctx->output->offset;
if (ctx->cur_dest_mail == NULL ||
mail_get_virtual_size(ctx->cur_dest_mail,
&ctx->file_last->vsize) < 0)
ctx->file_last->vsize = (uoff_t)-1;
- output_errno = ctx->output->stream_errno;
- o_stream_destroy(&ctx->output);
+ output_errno = _ctx->output->stream_errno;
+ o_stream_destroy(&_ctx->output);
if (!ctx->mbox->ibox.fsync_disable && !ctx->failed) {
if (fsync(ctx->fd) < 0) {
@@ -672,7 +671,7 @@ int maildir_transaction_save_commit_pre(
bool newdir, new_changed, cur_changed;
int ret;
- i_assert(ctx->output == NULL);
+ i_assert(ctx->ctx.output == NULL);
i_assert(ctx->finished);
sync_flags = MAILDIR_UIDLIST_SYNC_PARTIAL |
@@ -819,7 +818,7 @@ maildir_transaction_save_rollback_real(s
size_t dir_len;
bool hardlinks = FALSE;
- i_assert(ctx->output == NULL);
+ i_assert(ctx->ctx.output == NULL);
if (!ctx->finished)
maildir_save_cancel(&ctx->ctx);
diff -r 2a3fd0d46bc6 -r a05a7a73b475 src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h Mon Mar 09 21:00:48 2009 -0400
+++ b/src/lib-storage/mail-storage-private.h Mon Mar 09 21:52:42 2009 -0400
@@ -341,6 +341,7 @@ struct mail_save_context {
int received_tz_offset;
char *guid, *from_envelope;
+ struct ostream *output;
};
struct mailbox_sync_context {
More information about the dovecot-cvs
mailing list