]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Add mail_index_append_finish_uids_full()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 23 Jan 2019 15:22:27 +0000 (17:22 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Thu, 21 Mar 2019 08:02:47 +0000 (10:02 +0200)
src/lib-index/mail-index-transaction-update.c
src/lib-index/mail-index.h

index dae023f5345c2807a72e2f835832a7ac0cf0a35b..7354aa19d7d9c884fb183e1c8fe09729e908ec55 100644 (file)
@@ -194,6 +194,14 @@ void mail_index_append(struct mail_index_transaction *t, uint32_t uid,
 void mail_index_append_finish_uids(struct mail_index_transaction *t,
                                   uint32_t first_uid,
                                   ARRAY_TYPE(seq_range) *uids_r)
+{
+       return mail_index_append_finish_uids_full(t, first_uid, first_uid, uids_r);
+}
+
+void mail_index_append_finish_uids_full(struct mail_index_transaction *t,
+                                       uint32_t min_allowed_uid,
+                                       uint32_t first_new_uid,
+                                       ARRAY_TYPE(seq_range) *uids_r)
 {
        struct mail_index_record *recs;
        unsigned int i, count;
@@ -203,13 +211,14 @@ void mail_index_append_finish_uids(struct mail_index_transaction *t,
        if (!array_is_created(&t->appends))
                return;
 
-       i_assert(first_uid < (uint32_t)-1);
+       i_assert(min_allowed_uid <= first_new_uid);
+       i_assert(first_new_uid < (uint32_t)-1);
 
        /* first find the highest assigned uid */
        recs = array_get_modifiable(&t->appends, &count);
        i_assert(count > 0);
 
-       next_uid = first_uid;
+       next_uid = first_new_uid;
        for (i = 0; i < count; i++) {
                if (next_uid <= recs[i].uid)
                        next_uid = recs[i].uid + 1;
@@ -218,7 +227,7 @@ void mail_index_append_finish_uids(struct mail_index_transaction *t,
 
        /* assign missing uids */
        for (i = 0; i < count; i++) {
-               if (recs[i].uid == 0 || recs[i].uid < first_uid) {
+               if (recs[i].uid == 0 || recs[i].uid < min_allowed_uid) {
                        i_assert(next_uid < (uint32_t)-1);
                        recs[i].uid = next_uid++;
                        if (t->highest_append_uid < recs[i].uid)
index 8add21b74826440b20398f623124252bf30b4228..a54c41d9f6d952c932bb39178d253156e8943679 100644 (file)
@@ -555,11 +555,17 @@ void mail_index_lookup_first(struct mail_index_view *view,
 /* Append a new record to index. */
 void mail_index_append(struct mail_index_transaction *t, uint32_t uid,
                       uint32_t *seq_r);
-/* Assign UIDs for mails with uid=0 or uid<first_uid. All the assigned UIDs
-   are higher than the highest unassigned UID (i.e. it doesn't try to fill UID
-   gaps). Assumes that mailbox is locked in a way that UIDs can be safely
-   assigned. Returns UIDs for all assigned messages, in their sequence order
-   (so UIDs are not necessary ascending). */
+/* Assign new UIDs for mails with uid=0 or uid<min_allowed_uid. All the new
+   UIDs are >= first_new_uid, an also higher than the highest seen uid (i.e. it
+   doesn't try to fill UID gaps). Assumes that mailbox is locked in a way that
+   UIDs can be safely assigned. Returns UIDs for all assigned messages, in
+   their sequence order (so UIDs are not necessary ascending). */
+void mail_index_append_finish_uids_full(struct mail_index_transaction *t,
+                                       uint32_t min_allowed_uid,
+                                       uint32_t first_new_uid,
+                                       ARRAY_TYPE(seq_range) *uids_r);
+/* Call mail_index_append_finish_uids_full() with first_uid used for both
+   min_allowed_uid and first_new_uid. */
 void mail_index_append_finish_uids(struct mail_index_transaction *t,
                                   uint32_t first_uid,
                                   ARRAY_TYPE(seq_range) *uids_r);