]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: dsync - Search exportable mails with timestamps
authorAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 11 Nov 2025 06:38:38 +0000 (08:38 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Tue, 11 Nov 2025 10:46:09 +0000 (12:46 +0200)
This speeds up dsync with -t and -e, especially over network connection.

src/doveadm/dsync/dsync-brain-mailbox.c
src/doveadm/dsync/dsync-mailbox-export.c
src/doveadm/dsync/dsync-mailbox-export.h

index 84d25c18f7251850375b33984547e06fc2a6e5b2..3a17511a6df817a1f97a627b8fa05d02d82107e5 100644 (file)
@@ -355,6 +355,8 @@ int dsync_brain_sync_mailbox_open(struct dsync_brain *brain,
                .last_common_uid = last_common_uid,
                .flags = exporter_flags,
                .hdr_hash_version = brain->hdr_hash_version,
+               .sync_since_timestamp = brain->sync_since_timestamp,
+               .sync_until_timestamp = brain->sync_until_timestamp,
                .hashed_headers = brain->hashed_headers,
                .parent_event = brain->event,
        };
index 57b73fe81441aa8a20d950d5332847cbddd645dc..4d977515817d161dc822354bde00bb8866e5b6f7 100644 (file)
@@ -57,6 +57,9 @@ struct dsync_mailbox_exporter {
        struct dsync_mail_change change;
        struct dsync_mail dsync_mail;
 
+       time_t sync_since_timestamp;
+       time_t sync_until_timestamp;
+
        const char *error;
        enum mail_error mail_error;
 
@@ -403,6 +406,18 @@ dsync_mailbox_export_search(struct dsync_mailbox_exporter *exporter)
                wanted_headers = exporter->wanted_headers;
        }
 
+       if (exporter->sync_since_timestamp != 0) {
+               sarg = mail_search_build_add(search_args, SEARCH_SINCE);
+               sarg->value.date_type = MAIL_SEARCH_DATE_TYPE_RECEIVED;
+               sarg->value.time = exporter->sync_since_timestamp;
+       }
+
+       if (exporter->sync_until_timestamp != 0) {
+               sarg = mail_search_build_add(search_args, SEARCH_BEFORE);
+               sarg->value.date_type = MAIL_SEARCH_DATE_TYPE_RECEIVED;
+               sarg->value.time = exporter->sync_until_timestamp;
+       }
+
        exporter->trans = mailbox_transaction_begin(exporter->box,
                                                MAILBOX_TRANSACTION_FLAG_SYNC,
                                                __func__);
@@ -528,6 +543,8 @@ dsync_mailbox_export_init(struct mailbox *box,
        exporter->no_hdr_hashes =
                (set->flags & DSYNC_MAILBOX_EXPORTER_FLAG_NO_HDR_HASHES) != 0;
        exporter->hashed_headers = set->hashed_headers;
+       exporter->sync_since_timestamp = set->sync_since_timestamp;
+       exporter->sync_until_timestamp = set->sync_until_timestamp;
        exporter->event = event_create(set->parent_event);
 
        p_array_init(&exporter->requested_uids, pool, 16);
index f30ec8f1483503120a16bac60b91efe11284fe1d..0a42f657c1e693af276e052cf0226fcaf8703bdd 100644 (file)
@@ -15,6 +15,8 @@ struct dsync_mailbox_export_settings {
        enum dsync_mailbox_exporter_flags flags;
        unsigned int hdr_hash_version;
        const char *const *hashed_headers;
+       time_t sync_since_timestamp;
+       time_t sync_until_timestamp;
        struct event *parent_event;
 };