dovecot-2.0: maildir: Small code cleanup.
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jul 9 01:12:49 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/d5637a78d263
changeset: 9596:d5637a78d263
user: Timo Sirainen <tss at iki.fi>
date: Wed Jul 08 18:12:43 2009 -0400
description:
maildir: Small code cleanup.
diffstat:
3 files changed, 14 insertions(+), 54 deletions(-)
src/lib-storage/index/maildir/maildir-copy.c | 51 +++--------------------
src/lib-storage/index/maildir/maildir-save.c | 15 ++----
src/lib-storage/index/maildir/maildir-storage.h | 2
diffs (123 lines):
diff -r d4c1a2941c43 -r d5637a78d263 src/lib-storage/index/maildir/maildir-copy.c
--- 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 @@ maildir_copy_hardlink(struct maildir_tra
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_tra
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 -r d4c1a2941c43 -r d5637a78d263 src/lib-storage/index/maildir/maildir-save.c
--- 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 @@ maildir_save_transaction_init(struct mai
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
}
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_
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 -r d4c1a2941c43 -r d5637a78d263 src/lib-storage/index/maildir/maildir-storage.h
--- 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 @@ void maildir_save_cancel(struct mail_sav
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);
More information about the dovecot-cvs
mailing list