]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Maildir and Cydir: When saving mail, expose ostream to mail_save_context.output.
authorTimo Sirainen <tss@iki.fi>
Tue, 10 Mar 2009 01:52:42 +0000 (21:52 -0400)
committerTimo Sirainen <tss@iki.fi>
Tue, 10 Mar 2009 01:52:42 +0000 (21:52 -0400)
This would allow plugins to hook into it.

--HG--
branch : HEAD

src/lib-storage/index/cydir/cydir-save.c
src/lib-storage/index/maildir/maildir-save.c
src/lib-storage/mail-storage-private.h

index bb1e8f1a790bd9f9818647fd4d881c3a16455ec2..ca09bd70f4d7ce6056e5a21eb7427a3a4a768932 100644 (file)
@@ -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_context *_ctx, struct istream *input)
                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_context *_ctx)
                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_context *_ctx)
 
        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_context *_ctx)
                }
        }
 
-       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);
index e6812862b8ad179df7e4614e73335a1cfe9f62ec..1a754f4b619b725bd7d1bcbce144893f41f381a7 100644 (file)
@@ -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_context *_ctx, struct istream *input)
        } 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_save_context *_ctx)
                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(struct mail_save_context *_ctx)
        }
 
        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(struct mail_save_context *_ctx)
        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(struct maildir_save_context *ctx)
        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(struct maildir_save_context *ctx)
        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);
index 0beceabb5a3f150a4b92f69b95b82d661e53e1d2..1990bb78334d48a162c951d02e46d6e541301f71 100644 (file)
@@ -341,6 +341,7 @@ struct mail_save_context {
        int received_tz_offset;
 
        char *guid, *from_envelope;
+       struct ostream *output;
 };
 
 struct mailbox_sync_context {