From 3a2098a987b81fe89b74a9a628e9ef164f053633 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 8 Feb 2018 17:19:24 +0200 Subject: [PATCH] replication: Don't trigger replication on changes not visible to dsync For example if there's a write to .cache file, it doesn't require replication. --- src/plugins/replication/replication-plugin.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/replication/replication-plugin.c b/src/plugins/replication/replication-plugin.c index 461cfeeda3..1fa883cf8d 100644 --- a/src/plugins/replication/replication-plugin.c +++ b/src/plugins/replication/replication-plugin.c @@ -251,6 +251,15 @@ static void replication_mail_copy(void *txn, struct mail *src, } } +static bool +replication_want_sync_changes(const struct mail_transaction_commit_changes *changes) +{ + /* Replication needs to be triggered on all the user-visible changes, + but not e.g. due to writes to cache file. */ + return (changes->changes_mask & + ~MAIL_INDEX_TRANSACTION_CHANGE_OTHERS) != 0; +} + static void replication_mail_transaction_commit(void *txn, struct mail_transaction_commit_changes *changes) @@ -262,7 +271,7 @@ replication_mail_transaction_commit(void *txn, enum replication_priority priority; if (ruser != NULL && !ctx->sync_trans && - (ctx->new_messages || changes->changes_mask != 0)) { + (ctx->new_messages || replication_want_sync_changes(changes))) { priority = !ctx->new_messages ? REPLICATION_PRIORITY_LOW : ruser->sync_secs == 0 ? REPLICATION_PRIORITY_HIGH : REPLICATION_PRIORITY_SYNC; -- 2.47.3