From: Aki Tuomi Date: Tue, 11 Nov 2025 08:16:09 +0000 (+0200) Subject: doveadm: dsync - Search exportable mails with SMALLER X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d40140e34014432ed6c61f72acfb6b94b98295f;p=thirdparty%2Fdovecot%2Fcore.git doveadm: dsync - Search exportable mails with SMALLER This speeds up dsync with -I, especially over network connection. --- diff --git a/src/doveadm/dsync/dsync-brain-mailbox.c b/src/doveadm/dsync/dsync-brain-mailbox.c index 3a17511a6d..7c40af49f2 100644 --- a/src/doveadm/dsync/dsync-brain-mailbox.c +++ b/src/doveadm/dsync/dsync-brain-mailbox.c @@ -357,6 +357,7 @@ int dsync_brain_sync_mailbox_open(struct dsync_brain *brain, .hdr_hash_version = brain->hdr_hash_version, .sync_since_timestamp = brain->sync_since_timestamp, .sync_until_timestamp = brain->sync_until_timestamp, + .sync_max_size = brain->sync_max_size, .hashed_headers = brain->hashed_headers, .parent_event = brain->event, }; diff --git a/src/doveadm/dsync/dsync-mailbox-export.c b/src/doveadm/dsync/dsync-mailbox-export.c index 4d97751581..34907fcceb 100644 --- a/src/doveadm/dsync/dsync-mailbox-export.c +++ b/src/doveadm/dsync/dsync-mailbox-export.c @@ -59,6 +59,7 @@ struct dsync_mailbox_exporter { time_t sync_since_timestamp; time_t sync_until_timestamp; + uoff_t sync_max_size; const char *error; enum mail_error mail_error; @@ -418,6 +419,12 @@ dsync_mailbox_export_search(struct dsync_mailbox_exporter *exporter) sarg->value.time = exporter->sync_until_timestamp; } + if (exporter->sync_max_size != 0) { + sarg = mail_search_build_add(search_args, SEARCH_SMALLER); + /* the limit is <= but search criteria is < */ + sarg->value.size = exporter->sync_max_size + 1; + } + exporter->trans = mailbox_transaction_begin(exporter->box, MAILBOX_TRANSACTION_FLAG_SYNC, __func__); @@ -545,6 +552,7 @@ dsync_mailbox_export_init(struct mailbox *box, exporter->hashed_headers = set->hashed_headers; exporter->sync_since_timestamp = set->sync_since_timestamp; exporter->sync_until_timestamp = set->sync_until_timestamp; + exporter->sync_max_size = set->sync_max_size; exporter->event = event_create(set->parent_event); p_array_init(&exporter->requested_uids, pool, 16); diff --git a/src/doveadm/dsync/dsync-mailbox-export.h b/src/doveadm/dsync/dsync-mailbox-export.h index 0a42f657c1..ae4df9ea37 100644 --- a/src/doveadm/dsync/dsync-mailbox-export.h +++ b/src/doveadm/dsync/dsync-mailbox-export.h @@ -17,6 +17,7 @@ struct dsync_mailbox_export_settings { const char *const *hashed_headers; time_t sync_since_timestamp; time_t sync_until_timestamp; + uoff_t sync_max_size; struct event *parent_event; };