From: Timo Sirainen Date: Fri, 15 Jan 2016 13:12:30 +0000 (+0200) Subject: dsync: Fixed syncing subscription state with doveadm backup. X-Git-Tag: 2.2.22.rc1~357 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d7f23fa2334e037c09d8cf90cc80b3c89ecea27;p=thirdparty%2Fdovecot%2Fcore.git dsync: Fixed syncing subscription state with doveadm backup. If DSYNC_MAILBOX_TREES_SYNC_TYPE_PRESERVE_REMOTE was set, we could still have preserved the local subscription state. Also cleaned up the code a bit to make it clearer. --- diff --git a/src/doveadm/dsync/dsync-mailbox-tree-sync.c b/src/doveadm/dsync/dsync-mailbox-tree-sync.c index 4076d89322..64fa3f7adb 100644 --- a/src/doveadm/dsync/dsync-mailbox-tree-sync.c +++ b/src/doveadm/dsync/dsync-mailbox-tree-sync.c @@ -1254,11 +1254,22 @@ sync_subscription(struct dsync_mailbox_tree_sync_ctx *ctx, struct dsync_mailbox_node *local_node, struct dsync_mailbox_node *remote_node) { - if (ctx->sync_type == DSYNC_MAILBOX_TREES_SYNC_TYPE_PRESERVE_LOCAL || - local_node->last_subscription_change > - remote_node->last_subscription_change || - (local_node->last_subscription_change == - remote_node->last_subscription_change && local_node->subscribed)) { + bool use_local; + + if (ctx->sync_type == DSYNC_MAILBOX_TREES_SYNC_TYPE_PRESERVE_LOCAL) + use_local = TRUE; + else if (ctx->sync_type == DSYNC_MAILBOX_TREES_SYNC_TYPE_PRESERVE_REMOTE) + use_local = FALSE; + else if (local_node->last_subscription_change > remote_node->last_subscription_change) + use_local = TRUE; + else if (local_node->last_subscription_change < remote_node->last_subscription_change) + use_local = FALSE; + else { + /* local and remote have equal timestamps. prefer to subscribe + rather than unsubscribe. */ + use_local = local_node->subscribed; + } + if (use_local) { /* use local subscription state */ remote_node->subscribed = local_node->subscribed; } else {