# 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
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)
{
(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;
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;
}
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
static const struct maildir_settings maildir_default_settings = {
.maildir_copy_with_hardlinks = TRUE,
- .maildir_copy_preserve_filename = FALSE,
.maildir_very_dirty_syncs = FALSE
};