From: Timo Sirainen Date: Wed, 8 Jul 2009 22:12:43 +0000 (-0400) Subject: maildir: Small code cleanup. X-Git-Tag: 2.0.alpha1~456 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=303079fb1b356981de656c9b3d419a925c6e70a3;p=thirdparty%2Fdovecot%2Fcore.git maildir: Small code cleanup. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/maildir/maildir-copy.c b/src/lib-storage/index/maildir/maildir-copy.c index 2e0d158632..e2e5772388 100644 --- a/src/lib-storage/index/maildir/maildir-copy.c +++ b/src/lib-storage/index/maildir/maildir-copy.c @@ -184,36 +184,11 @@ maildir_copy_hardlink(struct maildir_transaction_context *t, struct mail *mail, 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 @@ maildir_copy_hardlink(struct maildir_transaction_context *t, struct mail *mail, 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; } diff --git a/src/lib-storage/index/maildir/maildir-save.c b/src/lib-storage/index/maildir/maildir-save.c index 56e01ca9f6..2f1b563772 100644 --- a/src/lib-storage/index/maildir/maildir-save.c +++ b/src/lib-storage/index/maildir/maildir-save.c @@ -134,12 +134,11 @@ maildir_save_transaction_init(struct maildir_transaction_context *t) 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 @@ uint32_t maildir_save_add(struct maildir_transaction_context *t, } 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 @@ 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(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; diff --git a/src/lib-storage/index/maildir/maildir-storage.h b/src/lib-storage/index/maildir/maildir-storage.h index c572597536..48d130c300 100644 --- a/src/lib-storage/index/maildir/maildir-storage.h +++ b/src/lib-storage/index/maildir/maildir-storage.h @@ -136,7 +136,7 @@ void maildir_save_cancel(struct mail_save_context *ctx); 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);