]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
maildir: Always try to preserve message GUIDs when copying.
authorTimo Sirainen <tss@iki.fi>
Thu, 18 Feb 2010 04:20:38 +0000 (06:20 +0200)
committerTimo Sirainen <tss@iki.fi>
Thu, 18 Feb 2010 04:20:38 +0000 (06:20 +0200)
Because of this, maildir_copy_preserve_filename setting is now removed.

--HG--
branch : HEAD

doc/example-config/conf.d/mail.conf
src/lib-storage/index/maildir/maildir-copy.c
src/lib-storage/index/maildir/maildir-settings.c
src/lib-storage/index/maildir/maildir-settings.h

index e53a6fab7306bb81f07b506e358cc86b82eb865e..1a22b87bda4d1f7f41102b3948bae19b0a708fc4 100644 (file)
 # the performance much better, and it's unlikely to have any side effects.
 #maildir_copy_with_hardlinks = yes
 
-# When copying a message, try to preserve the base filename. Only if the
-# destination mailbox already contains the same name (ie. the mail is being
-# copied there twice), a new name is given. The destination filename check is
-# done only by looking at dovecot-uidlist file, so if something outside
-# Dovecot does similar filename preserving copies, you may run into problems.
-# NOTE: This setting requires maildir_copy_with_hardlinks = yes to work.
-#maildir_copy_preserve_filename = no
-
 # Assume Dovecot is the only MUA accessing Maildir: Scan cur/ directory only
 # when its mtime changes unexpectedly or when we can't find the mail otherwise.
 #maildir_very_dirty_syncs = no
index 34e6dd6987900b987a89e473269248bc51d81b89..98aaaf24d2569241c241b9e5d4f799087e68ae5f 100644 (file)
@@ -123,22 +123,6 @@ static int do_hardlink(struct maildir_mailbox *mbox, const char *path,
        return 1;
 }
 
-static const char *
-maildir_copy_get_preserved_fname(struct maildir_mailbox *src_mbox,
-                                uint32_t uid)
-{
-       enum maildir_uidlist_rec_flag flags;
-       const char *fname;
-
-       if (maildir_uidlist_lookup(src_mbox->uidlist, uid, &flags,
-                                  &fname) <= 0)
-               return NULL;
-
-       /* fname may be freed by a later uidlist sync. make sure it gets
-          strduped. */
-       return t_strcut(t_strdup(fname), ':');
-}
-
 static int
 maildir_copy_hardlink(struct mail_save_context *ctx, struct mail *mail)
 {
@@ -146,7 +130,7 @@ maildir_copy_hardlink(struct mail_save_context *ctx, struct mail *mail)
                (struct maildir_mailbox *)ctx->transaction->box;
        struct maildir_mailbox *src_mbox;
        struct hardlink_ctx do_ctx;
-       const char *path, *filename = NULL;
+       const char *path, *guid;
 
        if (strcmp(mail->box->storage->name, MAILDIR_STORAGE_NAME) == 0)
                src_mbox = (struct maildir_mailbox *)mail->box;
@@ -161,17 +145,14 @@ maildir_copy_hardlink(struct mail_save_context *ctx, struct mail *mail)
        memset(&do_ctx, 0, sizeof(do_ctx));
        do_ctx.dest_path = str_new(default_pool, 512);
 
-       if (dest_mbox->storage->set->maildir_copy_preserve_filename &&
-           src_mbox != NULL) {
-               filename = maildir_copy_get_preserved_fname(src_mbox,
-                                                           mail->uid);
-       }
-       if (filename == NULL) {
+       if (mail_get_special(mail, MAIL_FETCH_GUID, &guid) < 0)
+               guid = "";
+       if (*guid == '\0') {
                /* the generated filename is _always_ unique, so we don't
                   bother trying to check if it already exists */
                do_ctx.dest_fname = maildir_filename_generate();
        } else {
-               do_ctx.dest_fname = filename;
+               do_ctx.dest_fname = guid;
                do_ctx.preserve_filename = TRUE;
        }
 
index 2064681cb02254a4fd86a44f8edefbab4f23b720..df4db9a98eb404194e8d7d3b3e0eca72dd0fe5df 100644 (file)
@@ -13,7 +13,6 @@
 
 static const struct setting_define maildir_setting_defines[] = {
        DEF(SET_BOOL, maildir_copy_with_hardlinks),
-       DEF(SET_BOOL, maildir_copy_preserve_filename),
        DEF(SET_BOOL, maildir_very_dirty_syncs),
 
        SETTING_DEFINE_LIST_END
@@ -21,7 +20,6 @@ static const struct setting_define maildir_setting_defines[] = {
 
 static const struct maildir_settings maildir_default_settings = {
        .maildir_copy_with_hardlinks = TRUE,
-       .maildir_copy_preserve_filename = FALSE,
        .maildir_very_dirty_syncs = FALSE
 };
 
index 47bf33b962102e2b8dcf9a57d28b00caa3a0f131..098afd9a5821e6e4369930c030c443aa4487bd1c 100644 (file)
@@ -3,7 +3,6 @@
 
 struct maildir_settings {
        bool maildir_copy_with_hardlinks;
-       bool maildir_copy_preserve_filename;
        bool maildir_very_dirty_syncs;
 };