virtual-sync.c revision fc80e0a7e5ce4376b40cc635ce5c3d88099c95b6
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen/* Copyright (c) 2008-2017 Dovecot authors, see the included COPYING file */
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen const char *const *kw_all;
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen /* messages expunged within this sync */
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen /* all messages in this sync, sorted by mailbox_id
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen (but unsorted inside it for now, since it doesn't matter) */
c57776c06ec99ba9b0dafdbf9475ea72ea8ca134Timo Sirainen uint32_t all_mails_idx, all_mails_prev_mailbox_id;
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainenstatic void virtual_sync_backend_box_deleted(struct virtual_sync_context *ctx,
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainenstatic void virtual_sync_set_uidvalidity(struct virtual_sync_context *ctx)
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainen offsetof(struct mail_index_header, uid_validity),
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainenstatic void virtual_sync_external_flags(struct virtual_sync_context *ctx,
b7c2065b3f10f9ae27787a9db5aaefbfc70d4502Timo Sirainen const char *const *kw_names;
0469ed17dafcc56589ce00960a23f4f06817dfb5Timo Sirainen if (!mail_set_uid(bbox->sync_mail, real_uid)) {
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen /* we may have reopened the mailbox, which could have
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen caused the mail to be expunged already. */
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen /* copy flags */
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen mail_index_update_flags(ctx->trans, vseq, MODIFY_REPLACE, flags);
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen /* copy keywords */
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen kw_names = mail_get_keywords(bbox->sync_mail);
0469ed17dafcc56589ce00960a23f4f06817dfb5Timo Sirainen keywords = mail_index_keywords_create(ctx->index, kw_names);
0469ed17dafcc56589ce00960a23f4f06817dfb5Timo Sirainen mail_index_update_keywords(ctx->trans, vseq, MODIFY_REPLACE, keywords);
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainenstatic int virtual_sync_mail_uid_cmp(const void *p1, const void *p2)
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen const struct virtual_sync_mail *m1 = p1, *m2 = p2;
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainen if (m1->vrec.mailbox_id < m2->vrec.mailbox_id)
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen if (m1->vrec.mailbox_id > m2->vrec.mailbox_id)
bool *broken_r)
const void *ext_data;
ext_name_offset = 0;
ext_mailbox_count = 0;
ret = 0;
const void *guid_data;
box_path);
ext_mailbox_count = 0;
ret = 0;
prev_mailbox_id = 0;
for (i = 0; i < ext_mailbox_count; i++) {
box_path);
box_path);
box_path);
T_BEGIN {
const unsigned char *nameptr;
const char *name;
} T_END;
if (ret < 0)
ret = 0;
if (i < ext_mailbox_count) {
ret = 0;
for (i = 0; i < count; i++) {
ret = 0;
return ret;
const void *ext_data;
for (i = 0; i < count; i++) {
i_assert(i == 0 ||
sizeof(struct virtual_mail_index_record),
sizeof(uint32_t));
const void *data;
if (flags != 0) {
if (flags != 0) {
kw_names);
int ret;
0, NULL);
return ret;
if (uid_count == 0)
i_unreached();
for (i = 0; i < uid_count; i++) {
&vseq))
if (uid_count == 0)
if (rec_count == 0 ||
&dest))
i_unreached();
for (i = 0; i < uid_count; i++) {
unsigned int i, count;
for (i = 0; i < count; i++) {
const void *data;
old_msg_count = 0;
&removed_uids);
unsigned int i, n = 0, count;
if (i == count)
for (; i < count; ) {
unsigned int i, n = 0, count;
for (; i < count; ) {
if (!iter_done) {
&added_uids);
&temp_uids);
&removed_uids);
&removed_uids);
unsigned int *idx1_r,
unsigned int *idx2_r)
&idx);
return FALSE;
return TRUE;
&idx1);
case MAILBOX_SYNC_TYPE_FLAGS:
case MAILBOX_SYNC_TYPE_MODSEQ:
const unsigned int uidval_pos =
unsigned int mailbox_offset;
int ret = 0;
if (ret == 0)
if (ret < 0) {
int ret;
return ret;
&status) < 0) {
return ret;
} T_END;
return ret;
const void *data;
unsigned int j = 0, uidmap_count = 0;
if (messages == 0)
for (i = 0; i < messages; i++) {
for (; j < uidmap_count; j++) {
&uidmap_count);
for (; j < uidmap_count; j++) {
for (; j < uidmap_count; j++) {
for (i = 0; i < count; i++) {
for (j = 0; j < uidmap_count; j++) {
unsigned int i, count;
if (count == 0) {
&idx))
i_unreached();
const void *data;
const void *data;
const void *mail_data;
unsigned int i, count;
int ret;
for (i = 0; i < count; i++) {
#ifdef DEBUG
for (i = 0; i < count; i++) {
return ret;
unsigned int i, count;
for (i = 0; i < count; i++)
if (success) {
return ret;
bool broken;
int ret;
if (ret <= 0) {
if (ret < 0)
return ret;
if (ret < 0)
if (ret == 0)
if (broken)
struct mailbox_sync_context *
int ret = 0;
return sync_ctx;