]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
maildir: Small code cleanup.
authorTimo Sirainen <tss@iki.fi>
Wed, 8 Jul 2009 22:12:43 +0000 (18:12 -0400)
committerTimo Sirainen <tss@iki.fi>
Wed, 8 Jul 2009 22:12:43 +0000 (18:12 -0400)
--HG--
branch : HEAD

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

index 2e0d158632b2cd2574dea3e1b22c085df3fe5b25..e2e5772388b7c7520295470701d486670ab68c8d 100644 (file)
@@ -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;
 }
 
index 56e01ca9f651a67a1ffda6078cbe6999edd8d5ed..2f1b56377265aa5e0d31395a1c48a84580987040 100644 (file)
@@ -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;
 
index c572597536982ebd3beb59c6ff9dc454fa2ca24d..48d130c300a561ee858d5e5d25a28df70027382e 100644 (file)
@@ -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);