bool replicator_notify:1;
bool exited:1;
bool empty_hdr_workaround:1;
+ bool no_header_hashes:1;
};
static bool legacy_dsync = FALSE;
brain_flags |= DSYNC_BRAIN_FLAG_NO_BACKUP_OVERWRITE;
if (ctx->empty_hdr_workaround)
brain_flags |= DSYNC_BRAIN_FLAG_EMPTY_HDR_WORKAROUND;
+ if (ctx->no_header_hashes)
+ brain_flags |= DSYNC_BRAIN_FLAG_NO_HEADER_HASHES;
if (doveadm_debug)
brain_flags |= DSYNC_BRAIN_FLAG_DEBUG;
p_array_init(&ctx->namespace_prefixes, ctx->ctx.pool, 4);
if ((doveadm_settings->parsed_features & DSYNC_FEATURE_EMPTY_HDR_WORKAROUND) != 0)
ctx->empty_hdr_workaround = TRUE;
+ if ((doveadm_settings->parsed_features & DSYNC_FEATURE_NO_HEADER_HASHES) != 0)
+ ctx->no_header_hashes = TRUE;
ctx->import_commit_msgs_interval = doveadm_settings->dsync_commit_msgs_interval;
return &ctx->ctx;
}
static const struct dsync_feature_list dsync_feature_list[] = {
{ "empty-header-workaround", DSYNC_FEATURE_EMPTY_HDR_WORKAROUND },
+ { "no-header-hashes", DSYNC_FEATURE_NO_HEADER_HASHES },
{ NULL, 0 }
};
/* <settings checks> */
enum dsync_features {
DSYNC_FEATURE_EMPTY_HDR_WORKAROUND = 0x1,
+ DSYNC_FEATURE_NO_HEADER_HASHES = 0x2,
};
/* </settings checks> */
import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_NO_NOTIFY;
if (brain->empty_hdr_workaround)
import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_EMPTY_HDR_WORKAROUND;
+ if (brain->no_header_hashes)
+ import_flags |= DSYNC_MAILBOX_IMPORT_FLAG_NO_HEADER_HASHES;
brain->box_importer = brain->backup_send ? NULL :
dsync_mailbox_import_init(brain->box, brain->virtual_all_box,
exporter_flags |= DSYNC_MAILBOX_EXPORTER_FLAG_TIMESTAMPS;
if (brain->sync_max_size > 0)
exporter_flags |= DSYNC_MAILBOX_EXPORTER_FLAG_VSIZES;
- if (remote_dsync_box->messages_count == 0) {
+ if (remote_dsync_box->messages_count == 0 ||
+ brain->no_header_hashes) {
/* remote mailbox is empty - we don't really need to export
header hashes since they're not going to match anything
anyway. */
bool no_notify:1;
bool failed:1;
bool empty_hdr_workaround:1;
+ bool no_header_hashes:1;
};
extern const char *dsync_box_state_names[DSYNC_BOX_STATE_DONE+1];
(flags & DSYNC_BRAIN_FLAG_NO_MAIL_PREFETCH) != 0;
brain->no_notify = (flags & DSYNC_BRAIN_FLAG_NO_NOTIFY) != 0;
brain->empty_hdr_workaround = (flags & DSYNC_BRAIN_FLAG_EMPTY_HDR_WORKAROUND) != 0;
+ brain->no_header_hashes = (flags & DSYNC_BRAIN_FLAG_NO_HEADER_HASHES) != 0;
}
static void
DSYNC_BRAIN_FLAG_NO_NOTIFY = 0x400,
/* Workaround missing Date/Message-ID headers */
DSYNC_BRAIN_FLAG_EMPTY_HDR_WORKAROUND = 0x800,
+ /* If mail GUIDs aren't supported, don't emulate them with header
+ hashes either. This trusts that all the existing mails with
+ identical UIDs have the same email content. This makes it slightly
+ less safe, but can have huge performance improvement with imapc
+ if the remote server doesn't have a fast header cache. */
+ DSYNC_BRAIN_FLAG_NO_HEADER_HASHES = 0x1000,
};
enum dsync_brain_sync_type {
bool mails_use_guid128:1;
bool delete_mailbox:1;
bool empty_hdr_workaround:1;
+ bool no_header_hashes:1;
};
static const char *dsync_mail_change_type_names[] = {
importer->hdr_hash_version = hdr_hash_version;
importer->empty_hdr_workaround =
(flags & DSYNC_MAILBOX_IMPORT_FLAG_EMPTY_HDR_WORKAROUND) != 0;
-
+ importer->no_header_hashes =
+ (flags & DSYNC_MAILBOX_IMPORT_FLAG_NO_HEADER_HASHES) != 0;
mailbox_get_open_status(importer->box, STATUS_UIDNEXT |
STATUS_HIGHESTMODSEQ | STATUS_HIGHESTPVTMODSEQ,
&status);
/* one of the headers is empty. assume it's broken and that
the header matches what we have currently. */
diff = 0;
+ } else if (importer->no_header_hashes && !importer->mails_have_guids &&
+ importer->cur_mail != NULL && save_change != NULL &&
+ (m1.guid[0] == '\0' || m2.guid[0] == '\0')) {
+ /* Header hashes aren't known. Assume that the mails match. */
+ diff = 0;
} else {
diff = importer_mail_cmp(&m1, &m2);
}
dsync_mail_hdr_hash_is_empty(hdr_hash))) {
*result_r = "Empty headers found with workaround enabled - assuming a match";
return 1;
+ } else if (importer->no_header_hashes &&
+ (change->hdr_hash[0] == '\0' || hdr_hash[0] == '\0')) {
+ *result_r = "Header hashing disabled - assuming a match";
+ return 1;
} else if (strcmp(change->hdr_hash, hdr_hash) == 0) {
*result_r = "Headers hashes match";
return 1;
DSYNC_MAILBOX_IMPORT_FLAG_MAILS_HAVE_GUIDS = 0x10,
DSYNC_MAILBOX_IMPORT_FLAG_MAILS_USE_GUID128 = 0x20,
DSYNC_MAILBOX_IMPORT_FLAG_NO_NOTIFY = 0x40,
- DSYNC_MAILBOX_IMPORT_FLAG_EMPTY_HDR_WORKAROUND = 0x100
+ DSYNC_MAILBOX_IMPORT_FLAG_EMPTY_HDR_WORKAROUND = 0x100,
+ DSYNC_MAILBOX_IMPORT_FLAG_NO_HEADER_HASHES = 0x200,
};
struct mailbox;