]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Reverted changes committed accidentally in previous commit.
authorTimo Sirainen <tss@iki.fi>
Thu, 9 Jul 2009 17:30:22 +0000 (13:30 -0400)
committerTimo Sirainen <tss@iki.fi>
Thu, 9 Jul 2009 17:30:22 +0000 (13:30 -0400)
--HG--
branch : HEAD

src/lib-storage/index/maildir/maildir-copy.c
src/lib-storage/index/maildir/maildir-save.c

index 5e98c0971d6d510c9754011aa8a6a9d60833ac32..e2e5772388b7c7520295470701d486670ab68c8d 100644 (file)
@@ -125,7 +125,9 @@ static int do_hardlink(struct maildir_mailbox *mbox, const char *path,
 }
 
 static int
-maildir_copy_hardlink(struct maildir_transaction_context *t, struct mail *mail)
+maildir_copy_hardlink(struct maildir_transaction_context *t, struct mail *mail,
+                     enum mail_flags flags, struct mail_keywords *keywords,
+                     struct mail *dest_mail)
 {
        struct maildir_mailbox *dest_mbox =
                (struct maildir_mailbox *)t->ictx.ibox;
@@ -148,6 +150,11 @@ maildir_copy_hardlink(struct maildir_transaction_context *t, struct mail *mail)
        if (t->save_ctx == NULL)
                t->save_ctx = maildir_save_transaction_init(t);
 
+       /* don't allow caller to specify recent flag */
+       flags &= ~MAIL_RECENT;
+       if (dest_mbox->ibox.keep_recent)
+               flags |= MAIL_RECENT;
+
        memset(&do_ctx, 0, sizeof(do_ctx));
        do_ctx.dest_path = str_new(default_pool, 512);
 
@@ -202,7 +209,8 @@ maildir_copy_hardlink(struct maildir_transaction_context *t, struct mail *mail)
        }
 
        /* hardlinked to tmp/, treat as normal copied mail */
-       maildir_save_add(t->save_ctx, do_ctx.dest_fname);
+       maildir_save_add(t->save_ctx, do_ctx.dest_fname, flags, keywords,
+                        dest_mail);
        return 1;
 }
 
@@ -223,7 +231,9 @@ int maildir_copy(struct mail_save_context *ctx, struct mail *mail)
        if (mbox->storage->set->maildir_copy_with_hardlinks &&
            maildir_compatible_file_modes(&mbox->ibox.box, mail->box)) {
                T_BEGIN {
-                       ret = maildir_copy_hardlink(t, mail);
+                       ret = maildir_copy_hardlink(t, mail, ctx->flags,
+                                                   ctx->keywords,
+                                                   ctx->dest_mail);
                } T_END;
 
                if (ret != 0) {
index b16b5c8656ea12875aa33e4a0c4980872fe17315..2f1b56377265aa5e0d31395a1c48a84580987040 100644 (file)
@@ -135,25 +135,22 @@ maildir_save_transaction_init(struct maildir_transaction_context *t)
 }
 
 uint32_t maildir_save_add(struct maildir_save_context *ctx,
-                         const char *base_fname)
+                         const char *base_fname, enum mail_flags flags,
+                         struct mail_keywords *keywords,
+                         struct mail *dest_mail)
 {
        struct maildir_filename *mf;
        struct istream *input;
 
-       /* don't allow caller to specify recent flag */
-       ctx->ctx.flags &= ~MAIL_RECENT;
-       if (dest_mbox->ibox.keep_recent)
-               ctx->ctx.flags |= MAIL_RECENT;
-
        /* now, we want to be able to rollback the whole append session,
           so we'll just store the name of this temp file and move it later
           into new/ or cur/. */
        /* @UNSAFE */
        mf = p_malloc(ctx->pool, sizeof(*mf) +
-                     sizeof(unsigned int) * (ctx->ctx.keywords == NULL ? 0 :
-                                             ctx->ctx.keywords->count));
+                     sizeof(unsigned int) * (keywords == NULL ? 0 :
+                                             keywords->count));
        mf->basename = p_strdup(ctx->pool, base_fname);
-       mf->flags = ctx->ctx.flags;
+       mf->flags = flags;
        mf->size = (uoff_t)-1;
        mf->vsize = (uoff_t)-1;
 
@@ -163,24 +160,22 @@ uint32_t maildir_save_add(struct maildir_save_context *ctx,
        ctx->files_tail = &mf->next;
        ctx->files_count++;
 
-       if (ctx->ctx.keywords != NULL) {
-               i_assert(sizeof(ctx->ctx.keywords->idx[0]) ==
-                        sizeof(unsigned int));
+       if (keywords != NULL) {
+               i_assert(sizeof(keywords->idx[0]) == sizeof(unsigned int));
 
                /* @UNSAFE */
-               mf->keywords_count = ctx->ctx.keywords->count;
-               memcpy(mf + 1, ctx->ctx.keywords->idx,
-                      sizeof(unsigned int) * ctx->ctx.keywords->count);
+               mf->keywords_count = keywords->count;
+               memcpy(mf + 1, keywords->idx,
+                      sizeof(unsigned int) * keywords->count);
                ctx->have_keywords = TRUE;
        }
 
        /* insert into index */
        mail_index_append(ctx->trans, 0, &ctx->seq);
-       mail_index_update_flags(ctx->trans, ctx->seq,
-                               MODIFY_REPLACE, ctx->ctx.flags);
-       if (ctx->ctx.keywords != NULL) {
+       mail_index_update_flags(ctx->trans, ctx->seq, MODIFY_REPLACE, flags);
+       if (keywords != NULL) {
                mail_index_update_keywords(ctx->trans, ctx->seq,
-                                          MODIFY_REPLACE, ctx->ctx.keywords);
+                                          MODIFY_REPLACE, keywords);
        }
 
        if (ctx->first_seq == 0) {
@@ -188,10 +183,10 @@ uint32_t maildir_save_add(struct maildir_save_context *ctx,
                i_assert(ctx->files->next == NULL);
        }
 
-       if (ctx->ctx.dest_mail == NULL) {
+       if (dest_mail == NULL) {
                if (ctx->mail == NULL)
                        ctx->mail = mail_alloc(ctx->ctx.transaction, 0, NULL);
-               ctx->ctx.dest_mail = ctx->mail;
+               dest_mail = ctx->mail;
        }
        mail_set_seq(dest_mail, ctx->seq);
 
@@ -376,6 +371,10 @@ int maildir_save_begin(struct mail_save_context *_ctx, struct istream *input)
                (struct maildir_transaction_context *)_ctx->transaction;
        struct maildir_save_context *ctx = (struct maildir_save_context *)_ctx;
 
+       _ctx->flags &= ~MAIL_RECENT;
+       if (ctx->mbox->ibox.keep_recent)
+               _ctx->flags |= MAIL_RECENT;
+
        T_BEGIN {
                /* create a new file in tmp/ directory */
                const char *fname = _ctx->guid;
@@ -388,7 +387,8 @@ int maildir_save_begin(struct mail_save_context *_ctx, struct istream *input)
                                ctx->input = i_stream_create_crlf(input);
                        else
                                ctx->input = i_stream_create_lf(input);
-                       maildir_save_add(ctx, fname);
+                       maildir_save_add(t->save_ctx, fname, _ctx->flags,
+                                        _ctx->keywords, _ctx->dest_mail);
                }
        } T_END;