From: Aki Tuomi Date: Tue, 11 Nov 2025 10:32:09 +0000 (+0200) Subject: doveadm: dsync - Sync mailbox before updating mailbox metadata X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=278311c2661321e24864a32d2d7cd051dcc4c922;p=thirdparty%2Fdovecot%2Fcore.git doveadm: dsync - Sync mailbox before updating mailbox metadata Fixes highestmodseq increasing unnecessarily after sync. --- diff --git a/src/doveadm/dsync/dsync-mailbox-import.c b/src/doveadm/dsync/dsync-mailbox-import.c index c879ca4061..2a19e8416d 100644 --- a/src/doveadm/dsync/dsync-mailbox-import.c +++ b/src/doveadm/dsync/dsync-mailbox-import.c @@ -2811,9 +2811,18 @@ static int dsync_mailbox_import_finish(struct dsync_mailbox_importer *importer, ret = dsync_mailbox_import_commit(importer, TRUE); + /* sync mailbox to finish flag changes and expunges. */ + if (mailbox_sync(importer->box, 0) < 0) { + e_error(importer->event, "Sync failed: %s", + mailbox_get_last_internal_error( + importer->box, &importer->mail_error)); + ret = -1; + } + if (ret == 0) { - /* update mailbox metadata if we successfully saved - everything. */ + /* Update mailbox metadata if we successfully saved + everything. Do this after syncing, which may update + modseqs. */ i_zero(&update); update.min_next_uid = importer->remote_uid_next; update.min_first_recent_uid = @@ -2837,13 +2846,6 @@ static int dsync_mailbox_import_finish(struct dsync_mailbox_importer *importer, } } - /* sync mailbox to finish flag changes and expunges. */ - if (mailbox_sync(importer->box, 0) < 0) { - e_error(importer->event, "Sync failed: %s", - mailbox_get_last_internal_error( - importer->box, &importer->mail_error)); - ret = -1; - } if (ret == 0) { /* give new UIDs to messages that got saved with unwanted UIDs. do it only if the whole transaction succeeded. */