Skip to content

Commit

Permalink
dsync: Fixed syncing subscription state with doveadm backup.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sirainen committed Jan 15, 2016
1 parent e21baa3 commit 9d7f23f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/doveadm/dsync/dsync-mailbox-tree-sync.c
Expand Up @@ -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 {
Expand Down

0 comments on commit 9d7f23f

Please sign in to comment.