Mercurial > dovecot > core-2.2
changeset 9596:d5637a78d263 HEAD
maildir: Small code cleanup.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 08 Jul 2009 18:12:43 -0400 |
parents | d4c1a2941c43 |
children | 771097ddce48 |
files | src/lib-storage/index/maildir/maildir-copy.c src/lib-storage/index/maildir/maildir-save.c src/lib-storage/index/maildir/maildir-storage.h |
diffstat | 3 files changed, 14 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-copy.c Wed Jul 08 17:58:02 2009 -0400 +++ b/src/lib-storage/index/maildir/maildir-copy.c Wed Jul 08 18:12:43 2009 -0400 @@ -184,36 +184,11 @@ do_ctx.preserve_filename = TRUE; } - /* FIXME: We could hardlink the files directly to destination, but - that would require checking if someone else had already assigned - UIDs for them after we have the uidlist locked. Index would also - need to be properly not-updated somehow.. */ -#if 0 - if (keywords == NULL || keywords->count == 0) { - /* no keywords, hardlink directly to destination */ - if (flags == MAIL_RECENT) { - str_printfa(do_ctx.dest_path, "%s/new/%s", - dest_mbox->path, do_ctx.dest_fname); - do_ctx.base_end_pos = str_len(do_ctx.dest_path); - } else { - str_printfa(do_ctx.dest_path, "%s/cur/", - dest_mbox->path); - do_ctx.base_end_pos = str_len(do_ctx.dest_path) + - strlen(do_ctx.dest_fname); - str_append(do_ctx.dest_path, - maildir_filename_set_flags(NULL, - do_ctx.dest_fname, - flags, NULL)); - } - } else -#endif - { - /* keywords, hardlink to tmp/ with basename and later when we - have uidlist locked, move it to new/cur. */ - str_printfa(do_ctx.dest_path, "%s/tmp/%s", - dest_mbox->ibox.box.path, do_ctx.dest_fname); - do_ctx.base_end_pos = str_len(do_ctx.dest_path); - } + /* hard link to tmp/ with basename and later when we + have uidlist locked, move it to new/cur. */ + str_printfa(do_ctx.dest_path, "%s/tmp/%s", + dest_mbox->ibox.box.path, do_ctx.dest_fname); + do_ctx.base_end_pos = str_len(do_ctx.dest_path); if (src_mbox != NULL) { /* maildir */ if (maildir_file_do(src_mbox, mail->uid, @@ -233,19 +208,9 @@ return 0; } -#if 0 - if (keywords == NULL || keywords->count == 0) { - /* hardlinked to destination, set hardlinked-flag */ - maildir_save_add(t, do_ctx.dest_fname, - flags | MAILDIR_SAVE_FLAG_HARDLINK, NULL, - dest_mail); - } else -#endif -{ - /* hardlinked to tmp/, treat as normal copied mail */ - maildir_save_add(t, do_ctx.dest_fname, flags, keywords, - dest_mail); - } + /* hardlinked to tmp/, treat as normal copied mail */ + maildir_save_add(t->save_ctx, do_ctx.dest_fname, flags, keywords, + dest_mail); return 1; }
--- a/src/lib-storage/index/maildir/maildir-save.c Wed Jul 08 17:58:02 2009 -0400 +++ b/src/lib-storage/index/maildir/maildir-save.c Wed Jul 08 18:12:43 2009 -0400 @@ -134,12 +134,11 @@ return ctx; } -uint32_t maildir_save_add(struct maildir_transaction_context *t, +uint32_t maildir_save_add(struct maildir_save_context *ctx, const char *base_fname, enum mail_flags flags, struct mail_keywords *keywords, struct mail *dest_mail) { - struct maildir_save_context *ctx = t->save_ctx; struct maildir_filename *mf; struct istream *input; @@ -185,12 +184,8 @@ } if (dest_mail == NULL) { - if (ctx->mail == NULL) { - struct mailbox_transaction_context *_t = - &t->ictx.mailbox_ctx; - - ctx->mail = mail_alloc(_t, 0, NULL); - } + if (ctx->mail == NULL) + ctx->mail = mail_alloc(ctx->ctx.transaction, 0, NULL); dest_mail = ctx->mail; } mail_set_seq(dest_mail, ctx->seq); @@ -392,8 +387,8 @@ ctx->input = i_stream_create_crlf(input); else ctx->input = i_stream_create_lf(input); - maildir_save_add(t, fname, _ctx->flags, _ctx->keywords, - _ctx->dest_mail); + maildir_save_add(t->save_ctx, fname, _ctx->flags, + _ctx->keywords, _ctx->dest_mail); } } T_END;
--- a/src/lib-storage/index/maildir/maildir-storage.h Wed Jul 08 17:58:02 2009 -0400 +++ b/src/lib-storage/index/maildir/maildir-storage.h Wed Jul 08 18:12:43 2009 -0400 @@ -136,7 +136,7 @@ struct maildir_save_context * maildir_save_transaction_init(struct maildir_transaction_context *t); -uint32_t maildir_save_add(struct maildir_transaction_context *t, +uint32_t maildir_save_add(struct maildir_save_context *ctx, const char *base_fname, enum mail_flags flags, struct mail_keywords *keywords, struct mail *dest_mail);