From: Aki Tuomi Date: Tue, 5 Sep 2017 07:43:46 +0000 (+0300) Subject: dsync: Ignore missing remote mailbox when doing unidirectional sync X-Git-Tag: 2.3.0.rc1~1109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=280bc7d8b07490dfa5cf0fc20aee8e9e2d15aa99;p=thirdparty%2Fdovecot%2Fcore.git dsync: Ignore missing remote mailbox when doing unidirectional sync If there are some folders on remote system that are being ignored by remote brain, do not error out. --- diff --git a/src/doveadm/dsync/dsync-brain-mailbox.c b/src/doveadm/dsync/dsync-brain-mailbox.c index 454d90ceb4..f4faa34f87 100644 --- a/src/doveadm/dsync/dsync-brain-mailbox.c +++ b/src/doveadm/dsync/dsync-brain-mailbox.c @@ -719,7 +719,8 @@ bool dsync_brain_mailbox_update_pre(struct dsync_brain *brain, static void dsync_brain_slave_send_mailbox_lost(struct dsync_brain *brain, - const struct dsync_mailbox *dsync_box) + const struct dsync_mailbox *dsync_box, + bool ignore) { struct dsync_mailbox delete_box; @@ -732,7 +733,10 @@ dsync_brain_slave_send_mailbox_lost(struct dsync_brain *brain, memcpy(delete_box.mailbox_guid, dsync_box->mailbox_guid, sizeof(delete_box.mailbox_guid)); t_array_init(&delete_box.cache_fields, 0); - delete_box.mailbox_lost = TRUE; + if (ignore) + delete_box.mailbox_ignore = TRUE; + else + delete_box.mailbox_lost = TRUE; dsync_ibc_send_mailbox(brain->ibc, &delete_box); } @@ -773,14 +777,14 @@ bool dsync_brain_slave_recv_mailbox(struct dsync_brain *brain) brain->master_brain ? 'M' : 'S', guid_128_to_string(dsync_box->mailbox_guid)); } - dsync_brain_slave_send_mailbox_lost(brain, dsync_box); + dsync_brain_slave_send_mailbox_lost(brain, dsync_box, TRUE); return TRUE; } //FIXME: verify this from log, and if not log an error. dsync_brain_set_changes_during_sync(brain, t_strdup_printf( "Mailbox GUID %s was lost", guid_128_to_string(dsync_box->mailbox_guid))); - dsync_brain_slave_send_mailbox_lost(brain, dsync_box); + dsync_brain_slave_send_mailbox_lost(brain, dsync_box, FALSE); return TRUE; } if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) { @@ -805,7 +809,7 @@ bool dsync_brain_slave_recv_mailbox(struct dsync_brain *brain) brain->master_brain ? 'M' : 'S', guid_128_to_string(dsync_box->mailbox_guid)); } - dsync_brain_slave_send_mailbox_lost(brain, dsync_box); + dsync_brain_slave_send_mailbox_lost(brain, dsync_box, FALSE); return TRUE; } i_assert(local_dsync_box.uid_validity != 0); @@ -836,7 +840,7 @@ bool dsync_brain_slave_recv_mailbox(struct dsync_brain *brain) if (ret == 0 || resync) { brain->require_full_resync = TRUE; dsync_brain_sync_mailbox_deinit(brain); - dsync_brain_slave_send_mailbox_lost(brain, dsync_box); + dsync_brain_slave_send_mailbox_lost(brain, dsync_box, FALSE); return TRUE; } diff --git a/src/doveadm/dsync/dsync-brain-mails.c b/src/doveadm/dsync/dsync-brain-mails.c index 59dc052cfe..44e53038c6 100644 --- a/src/doveadm/dsync/dsync-brain-mails.c +++ b/src/doveadm/dsync/dsync-brain-mails.c @@ -41,6 +41,15 @@ static bool dsync_brain_master_sync_recv_mailbox(struct dsync_brain *brain) return TRUE; } + if (dsync_box->mailbox_ignore) { + /* ignore this box */ + if (brain->debug) + i_debug("brain %c: Ignoring missing remote box GUID %s", + brain->master_brain ? 'M' : 'S', + guid_128_to_string(dsync_box->mailbox_guid)); + dsync_brain_sync_mailbox_deinit(brain); + return TRUE; + } if (dsync_box->mailbox_lost) { /* remote lost the mailbox. it's probably already deleted, but verify it on next sync just to be sure */ diff --git a/src/doveadm/dsync/dsync-ibc-stream.c b/src/doveadm/dsync/dsync-ibc-stream.c index 1795443b2d..878013821f 100644 --- a/src/doveadm/dsync/dsync-ibc-stream.c +++ b/src/doveadm/dsync/dsync-ibc-stream.c @@ -102,7 +102,8 @@ static const struct { .chr = 'B', .required_keys = "mailbox_guid uid_validity uid_next messages_count " "first_recent_uid highest_modseq highest_pvt_modseq", - .optional_keys = "mailbox_lost cache_fields have_guids have_save_guids have_only_guid128" + .optional_keys = "mailbox_lost mailbox_ignore " + "cache_fields have_guids have_save_guids have_only_guid128" }, { .name = "mailbox_attribute", .chr = 'A', @@ -1310,6 +1311,8 @@ dsync_ibc_stream_send_mailbox(struct dsync_ibc *_ibc, if (dsync_box->mailbox_lost) dsync_serializer_encode_add(encoder, "mailbox_lost", ""); + if (dsync_box->mailbox_ignore) + dsync_serializer_encode_add(encoder, "mailbox_ignore", ""); if (dsync_box->have_guids) dsync_serializer_encode_add(encoder, "have_guids", ""); if (dsync_box->have_save_guids) @@ -1414,6 +1417,8 @@ dsync_ibc_stream_recv_mailbox(struct dsync_ibc *_ibc, if (dsync_deserializer_decode_try(decoder, "mailbox_lost", &value)) box->mailbox_lost = TRUE; + if (dsync_deserializer_decode_try(decoder, "mailbox_ignore", &value)) + box->mailbox_ignore = TRUE; if (dsync_deserializer_decode_try(decoder, "have_guids", &value)) box->have_guids = TRUE; if (dsync_deserializer_decode_try(decoder, "have_save_guids", &value) || diff --git a/src/doveadm/dsync/dsync-mailbox.h b/src/doveadm/dsync/dsync-mailbox.h index 4e0254369c..d3dda9ddbb 100644 --- a/src/doveadm/dsync/dsync-mailbox.h +++ b/src/doveadm/dsync/dsync-mailbox.h @@ -8,6 +8,7 @@ struct dsync_mailbox { guid_128_t mailbox_guid; bool mailbox_lost; + bool mailbox_ignore; bool have_guids, have_save_guids, have_only_guid128; uint32_t uid_validity, uid_next, messages_count, first_recent_uid;