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;
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;
/* 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)
/* 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);