enum mail_flags save_flags;
struct istream *crlf_input;
- if (mail_index_is_deleted(ctx->mbox->ibox.index)) {
+ if (mail_index_is_deleted(trans->box->index)) {
mailbox_set_deleted(trans->box);
return -1;
}
mbox->ibox.box.pool = pool;
mbox->ibox.box.storage = storage;
mbox->ibox.box.list = list;
- mbox->ibox.mail_vfuncs = &cydir_mail_vfuncs;
+ mbox->ibox.box.mail_vfuncs = &cydir_mail_vfuncs;
mbox->ibox.save_commit_pre = cydir_transaction_save_commit_pre;
mbox->ibox.save_commit_post = cydir_transaction_save_commit_post;
index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
CYDIR_INDEX_PREFIX);
- mail_index_set_fsync_types(mbox->ibox.index,
+ mail_index_set_fsync_types(mbox->ibox.box.index,
MAIL_INDEX_SYNC_TYPE_APPEND |
MAIL_INDEX_SYNC_TYPE_EXPUNGE);
if (!force)
sync_flags |= MAIL_INDEX_SYNC_FLAG_REQUIRE_CHANGES;
- ret = mail_index_sync_begin(mbox->ibox.index, &ctx->index_sync_ctx,
+ ret = mail_index_sync_begin(mbox->ibox.box.index, &ctx->index_sync_ctx,
&ctx->sync_view, &ctx->trans,
sync_flags);
if (ret <= 0) {
if (ret < 0)
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(&mbox->ibox.box);
i_free(ctx);
*ctx_r = NULL;
return ret;
*_ctx = NULL;
if (success) {
if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
- mail_storage_set_index_error(&ctx->mbox->ibox);
+ mail_storage_set_index_error(&ctx->mbox->ibox.box);
ret = -1;
}
} else {
ctx->trans = trans;
mail_index_reset(ctx->trans);
index_mailbox_reset_uidvalidity(ibox);
- mail_index_ext_lookup(ibox->index, "cache", &ctx->cache_ext_id);
+ mail_index_ext_lookup(box->index, "cache", &ctx->cache_ext_id);
/* if backup index file exists, try to use it */
index_dir = mailbox_list_get_path(box->list, box->name,
struct mdbox_mailbox *mbox = (struct mdbox_mailbox *)mail->imail.ibox;
struct mail *_mail = &mail->imail.mail.mail;
- (void)mail_index_refresh(mbox->ibox.index);
- if (mail_index_is_expunged(mbox->ibox.view, _mail->seq)) {
+ (void)mail_index_refresh(_mail->box->index);
+ if (mail_index_is_expunged(_mail->box->view, _mail->seq)) {
mail_set_expunged(_mail);
return;
}
if (mail->open_file != NULL) {
/* already open */
} else if (_mail->uid != 0) {
- if (mdbox_mail_lookup(mbox, mbox->ibox.view, _mail->seq,
- &map_uid) < 0)
+ if (mdbox_mail_lookup(mbox, _mail->box->view,
+ _mail->seq, &map_uid) < 0)
return -1;
if (dbox_mail_open_init(mail, map_uid) < 0)
return -1;
const void *data;
bool expunged;
- mail_index_lookup_ext(mbox->ibox.view, mail->seq,
+ mail_index_lookup_ext(mail->box->view, mail->seq,
mbox->ext_id, &data, &expunged);
dbox_rec = data;
if (dbox_rec == NULL || dbox_rec->map_uid == 0) {
struct dbox_save_mail *save_mail;
uoff_t mail_size, append_offset;
- if (mail_index_is_deleted(ctx->mbox->ibox.index)) {
+ if (mail_index_is_deleted(_ctx->transaction->box->index)) {
mailbox_set_deleted(_ctx->transaction->box);
return -1;
}
memset(&rec, 0, sizeof(rec));
rec.save_date = ioloop_time;
- if (mdbox_mail_lookup(src_mbox, src_mbox->ibox.view, mail->seq,
+ if (mdbox_mail_lookup(src_mbox, mail->box->view, mail->seq,
&rec.map_uid) < 0)
return -1;
mail_index_update_ext(ctx->ctx.trans, ctx->ctx.seq,
ctx->mbox->ext_id, &rec, NULL);
- mail_index_lookup_ext(src_mbox->ibox.view, mail->seq,
+ mail_index_lookup_ext(mail->box->view, mail->seq,
src_mbox->guid_ext_id, &data, &expunged);
if (data != NULL) {
mail_index_update_ext(ctx->ctx.trans, ctx->ctx.seq,
}
mbox = (struct mdbox_mailbox *)box;
- ret = mail_index_sync_begin(mbox->ibox.index, &sync_ctx, &view, &trans,
+ ret = mail_index_sync_begin(box->index, &sync_ctx, &view, &trans,
MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES);
if (ret <= 0) {
i_assert(ret != 0);
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(box);
mailbox_close(&box);
return -1;
}
dbox_sync_index_rebuild_deinit(&rebuild_ctx);
if (mail_index_sync_commit(&sync_ctx) < 0) {
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(box);
ret = -1;
}
return -1;
}
if (ctx->prev_msg.box == NULL) {
- ret = mail_index_sync_begin(mbox->ibox.index,
+ ret = mail_index_sync_begin(box->index,
&ctx->prev_msg.sync_ctx,
&ctx->prev_msg.view,
&ctx->prev_msg.trans, 0);
if (ret <= 0) {
i_assert(ret != 0);
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(box);
mailbox_close(&box);
return -1;
}
mbox->ibox.box.pool = pool;
mbox->ibox.box.storage = storage;
mbox->ibox.box.list = list;
- mbox->ibox.mail_vfuncs = &mdbox_mail_vfuncs;
+ mbox->ibox.box.mail_vfuncs = &mdbox_mail_vfuncs;
mbox->ibox.save_commit_pre = mdbox_transaction_save_commit_pre;
mbox->ibox.save_commit_post = mdbox_transaction_save_commit_post;
index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
DBOX_INDEX_PREFIX);
- mail_index_set_fsync_types(mbox->ibox.index,
+ mail_index_set_fsync_types(mbox->ibox.box.index,
MAIL_INDEX_SYNC_TYPE_APPEND |
MAIL_INDEX_SYNC_TYPE_EXPUNGE);
mbox->storage = (struct mdbox_storage *)storage;
mbox->ext_id =
- mail_index_ext_register(mbox->ibox.index, "mdbox", 0,
+ mail_index_ext_register(mbox->ibox.box.index, "mdbox", 0,
sizeof(struct mdbox_mail_index_record),
sizeof(uint32_t));
mbox->hdr_ext_id =
- mail_index_ext_register(mbox->ibox.index, "mdbox-hdr",
+ mail_index_ext_register(mbox->ibox.box.index, "mdbox-hdr",
sizeof(struct mdbox_index_header), 0, 0);
mbox->guid_ext_id =
- mail_index_ext_register(mbox->ibox.index, "guid",
+ mail_index_ext_register(mbox->ibox.box.index, "guid",
0, MAIL_GUID_128_SIZE, 1);
return &mbox->ibox.box;
}
const void *data;
size_t data_size;
- mail_index_get_header_ext(mbox->ibox.view, mbox->hdr_ext_id,
+ mail_index_get_header_ext(mbox->ibox.box.view, mbox->hdr_ext_id,
&data, &data_size);
if (data_size < MDBOX_INDEX_HEADER_MIN_SIZE &&
(!mbox->creating || data_size != 0)) {
if (dbox_map_open(mbox->storage->map, TRUE) < 0)
return -1;
- hdr = mail_index_get_header(mbox->ibox.view);
- trans = mail_index_transaction_begin(mbox->ibox.view, 0);
+ hdr = mail_index_get_header(box->view);
+ trans = mail_index_transaction_begin(box->view, 0);
mdbox_update_header(mbox, trans, update);
uid_validity = hdr->uid_validity;
&uid_next, sizeof(uid_next), TRUE);
}
if (update != NULL && update->min_highest_modseq != 0 &&
- mail_index_modseq_get_highest(mbox->ibox.view) <
+ mail_index_modseq_get_highest(box->view) <
update->min_highest_modseq) {
mail_index_update_highest_modseq(trans,
update->min_highest_modseq);
if (mail_index_transaction_commit(&trans) < 0) {
mail_storage_set_internal_error(box->storage);
- mail_index_reset_error(mbox->ibox.index);
+ mail_index_reset_error(box->index);
return -1;
}
return 0;
/* get a list of all map_uids in this mailbox */
i_array_init(&map_uids, 128);
- hdr = mail_index_get_header(mbox->ibox.view);
+ hdr = mail_index_get_header(box->view);
for (seq = 1; seq <= hdr->messages_count; seq++) {
- mail_index_lookup_ext(mbox->ibox.view, seq, mbox->ext_id,
+ mail_index_lookup_ext(box->view, seq, mbox->ext_id,
&data, &expunged);
dbox_rec = data;
if (dbox_rec == NULL) {
struct mdbox_index_header hdr;
int ret;
- view = mail_index_view_open(mbox->ibox.index);
+ view = mail_index_view_open(mbox->ibox.box.index);
ret = mdbox_read_header(mbox, &hdr);
mail_index_view_close(&view);
if (ret == 0) {
ret = mbox->storage->storage.files_corrupted ? -1 : 0;
} else if (retry) {
- (void)mail_index_refresh(mbox->ibox.index);
+ (void)mail_index_refresh(mbox->ibox.box.index);
return mdbox_refresh_header(mbox, FALSE);
}
return ret;
sync_flags |= MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES;
for (i = 0;; i++) {
- ret = mail_index_sync_begin(mbox->ibox.index,
+ ret = mail_index_sync_begin(mbox->ibox.box.index,
&ctx->index_sync_ctx,
&ctx->sync_view, &ctx->trans,
sync_flags);
if (ret <= 0) {
if (ret < 0)
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(&mbox->ibox.box);
i_free(ctx);
*ctx_r = NULL;
return ret;
if (success) {
if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
- mail_storage_set_index_error(&ctx->mbox->ibox);
+ mail_storage_set_index_error(&ctx->mbox->ibox.box);
ret = -1;
}
} else {
struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)mail->imail.ibox;
struct mail *_mail = &mail->imail.mail.mail;
- (void)mail_index_refresh(mbox->ibox.index);
- if (mail_index_is_expunged(mbox->ibox.view, _mail->seq)) {
+ (void)mail_index_refresh(_mail->box->index);
+ if (mail_index_is_expunged(_mail->box->view, _mail->seq)) {
mail_set_expunged(_mail);
return;
}
struct dbox_file *file;
int ret;
- if (mail_index_is_deleted(ctx->mbox->ibox.index)) {
+ if (mail_index_is_deleted(_ctx->transaction->box->index)) {
mailbox_set_deleted(_ctx->transaction->box);
return -1;
}
mbox->ibox.box.pool = pool;
mbox->ibox.box.storage = storage;
mbox->ibox.box.list = list;
- mbox->ibox.mail_vfuncs = &sdbox_mail_vfuncs;
+ mbox->ibox.box.mail_vfuncs = &sdbox_mail_vfuncs;
mbox->ibox.save_commit_pre = sdbox_transaction_save_commit_pre;
mbox->ibox.save_commit_post = sdbox_transaction_save_commit_post;
index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
DBOX_INDEX_PREFIX);
- mail_index_set_fsync_types(mbox->ibox.index,
+ mail_index_set_fsync_types(mbox->ibox.box.index,
MAIL_INDEX_SYNC_TYPE_APPEND |
MAIL_INDEX_SYNC_TYPE_EXPUNGE);
p_strconcat(pool, list->set.alt_dir, "/",
list->set.maildir_name, NULL);
mbox->hdr_ext_id =
- mail_index_ext_register(mbox->ibox.index, "dbox-hdr",
+ mail_index_ext_register(mbox->ibox.box.index, "dbox-hdr",
sizeof(struct sdbox_index_header), 0, 0);
return &mbox->ibox.box;
}
const void *data;
size_t data_size;
- mail_index_get_header_ext(mbox->ibox.view, mbox->hdr_ext_id,
+ mail_index_get_header_ext(mbox->ibox.box.view, mbox->hdr_ext_id,
&data, &data_size);
if (data_size < SDBOX_INDEX_HEADER_MIN_SIZE &&
(!mbox->creating || data_size != 0)) {
const struct mail_index_header *hdr;
uint32_t uid_validity, uid_next;
- hdr = mail_index_get_header(mbox->ibox.view);
- trans = mail_index_transaction_begin(mbox->ibox.view, 0);
+ hdr = mail_index_get_header(box->view);
+ trans = mail_index_transaction_begin(box->view, 0);
sdbox_update_header(mbox, trans, update);
if (update != NULL && update->uid_validity != 0)
&uid_next, sizeof(uid_next), TRUE);
}
if (update != NULL && update->min_highest_modseq != 0 &&
- mail_index_modseq_get_highest(mbox->ibox.view) <
+ mail_index_modseq_get_highest(box->view) <
update->min_highest_modseq) {
mail_index_update_highest_modseq(trans,
update->min_highest_modseq);
if (mail_index_transaction_commit(&trans) < 0) {
mail_storage_set_internal_error(box->storage);
- mail_index_reset_error(mbox->ibox.index);
+ mail_index_reset_error(box->index);
return -1;
}
return 0;
struct mail_index_transaction *trans;
int ret;
- view = mail_index_view_open(mbox->ibox.index);
+ view = mail_index_view_open(mbox->ibox.box.index);
trans = mail_index_transaction_begin(view,
MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL);
struct sdbox_index_header hdr;
int ret;
- view = mail_index_view_open(mbox->ibox.index);
+ view = mail_index_view_open(mbox->ibox.box.index);
ret = sdbox_read_header(mbox, &hdr);
mail_index_view_close(&view);
if (ret == 0) {
ret = mbox->sync_rebuild ? -1 : 0;
} else if (retry) {
- (void)mail_index_refresh(mbox->ibox.index);
+ (void)mail_index_refresh(mbox->ibox.box.index);
return sdbox_refresh_header(mbox, FALSE);
}
return ret;
sync_flags |= MAIL_INDEX_SYNC_FLAG_AVOID_FLAG_UPDATES;
for (i = 0;; i++) {
- ret = mail_index_sync_begin(mbox->ibox.index,
+ ret = mail_index_sync_begin(mbox->ibox.box.index,
&ctx->index_sync_ctx,
&ctx->sync_view, &ctx->trans,
sync_flags);
if (ret <= 0) {
if (ret < 0)
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(&mbox->ibox.box);
i_free(ctx);
*ctx_r = NULL;
return ret;
if (success) {
if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
- mail_storage_set_index_error(&ctx->mbox->ibox);
+ mail_storage_set_index_error(&ctx->mbox->ibox.box);
ret = -1;
}
} else {
uint32_t uid1, uint32_t uid2,
uint32_t *seq1_r, uint32_t *seq2_r)
{
- struct index_mailbox *ibox = (struct index_mailbox *)box;
-
- mail_index_lookup_seq_range(ibox->view, uid1, uid2, seq1_r, seq2_r);
+ mail_index_lookup_seq_range(box->view, uid1, uid2, seq1_r, seq2_r);
}
void index_storage_get_uid_range(struct mailbox *box,
const ARRAY_TYPE(seq_range) *seqs,
ARRAY_TYPE(seq_range) *uids)
{
- struct index_mailbox *ibox = (struct index_mailbox *)box;
const struct seq_range *range;
unsigned int i, count;
uint32_t seq, uid;
for (i = 0; i < count; i++) {
if (range[i].seq2 == (uint32_t)-1) {
i_assert(count == i-1);
- mail_index_lookup_uid(ibox->view, range[i].seq1, &uid);
+ mail_index_lookup_uid(box->view, range[i].seq1, &uid);
seq_range_array_add_range(uids, uid, (uint32_t)-1);
break;
}
for (seq = range[i].seq1; seq <= range[i].seq2; seq++) {
- mail_index_lookup_uid(ibox->view, seq, &uid);
+ mail_index_lookup_uid(box->view, seq, &uid);
seq_range_array_add(uids, 0, uid);
}
}
const ARRAY_TYPE(seq_range) *uids_filter,
ARRAY_TYPE(mailbox_expunge_rec) *expunges)
{
- struct index_mailbox *ibox = (struct index_mailbox *)box;
struct mail_transaction_log_view *log_view;
const struct mail_transaction_header *thdr;
const void *tdata;
bool reset;
int ret;
- if (!mail_index_modseq_get_next_log_offset(ibox->view, prev_modseq,
+ if (!mail_index_modseq_get_next_log_offset(box->view, prev_modseq,
&log_seq, &log_offset))
return FALSE;
- if (log_seq > ibox->view->log_file_head_seq ||
- (log_seq == ibox->view->log_file_head_seq &&
- log_offset >= ibox->view->log_file_head_offset)) {
+ if (log_seq > box->view->log_file_head_seq ||
+ (log_seq == box->view->log_file_head_seq &&
+ log_offset >= box->view->log_file_head_offset)) {
/* we haven't seen this high expunges at all */
return TRUE;
}
- log_view = mail_transaction_log_view_open(ibox->index->log);
+ log_view = mail_transaction_log_view_open(box->index->log);
ret = mail_transaction_log_view_set(log_view, log_seq, log_offset,
- ibox->view->log_file_head_seq,
- ibox->view->log_file_head_offset,
+ box->view->log_file_head_seq,
+ box->view->log_file_head_offset,
&reset);
if (ret == 0) {
- mail_transaction_log_get_tail(ibox->index->log, &tail_seq);
+ mail_transaction_log_get_tail(box->index->log, &tail_seq);
i_assert(tail_seq > log_seq);
ret = mail_transaction_log_view_set(log_view, tail_seq, 0,
- ibox->view->log_file_head_seq,
- ibox->view->log_file_head_offset,
+ box->view->log_file_head_seq,
+ box->view->log_file_head_offset,
&reset);
i_assert(ret != 0);
}
}
static unsigned int
-get_header_field_idx(struct index_mailbox *ibox, const char *field,
+get_header_field_idx(struct mailbox *box, const char *field,
enum mail_cache_decision_type decision)
{
struct mail_cache_field header_field = {
header_field.decision = decision;
T_BEGIN {
header_field.name = t_strconcat("hdr.", field, NULL);
- mail_cache_register_fields(ibox->cache, &header_field, 1);
+ mail_cache_register_fields(box->cache, &header_field, 1);
} T_END;
return header_field.idx;
}
unsigned int i, count;
all_cache_fields =
- mail_cache_register_get_list(mail->ibox->cache,
+ mail_cache_register_get_list(mail->ibox->box.cache,
pool_datastack_create(), &count);
for (i = 0; i < count; i++) {
if (strncasecmp(all_cache_fields[i].name, "hdr.", 4) != 0)
Date: header. if we have Date field's index set at this point we
know that we want it. otherwise add it and remember that we don't
want it cached. */
- field_idx = get_header_field_idx(mail->ibox, "Date",
+ field_idx = get_header_field_idx(&mail->ibox->box, "Date",
MAIL_CACHE_DECISION_NO);
match = array_get(&mail->header_match, &match_count);
if (field_idx < match_count &&
const char *cache_field_name =
t_strconcat("hdr.", hdr->name, NULL);
data->parse_line.field_idx =
- mail_cache_register_lookup(mail->ibox->cache,
+ mail_cache_register_lookup(mail->ibox->box.cache,
cache_field_name);
} T_END;
}
i_assert(field != NULL);
- field_idx = get_header_field_idx(mail->ibox, field,
+ field_idx = get_header_field_idx(&mail->ibox->box, field,
MAIL_CACHE_DECISION_TEMP);
dest = str_new(mail->data_pool, 128);
} T_END;
if (ret < 0) {
- mail_cache_set_corrupted(mail->ibox->cache,
+ mail_cache_set_corrupted(_mail->box->cache,
"Broken header %s for mail UID %u",
field, _mail->uid);
}
} T_END;
if (ret < 0) {
- mail_cache_set_corrupted(mail->ibox->cache,
+ mail_cache_set_corrupted(_mail->box->cache,
"Broken header %s for mail UID %u",
field, _mail->uid);
}
static struct mailbox_header_lookup_ctx *
index_header_lookup_init_real(struct mailbox *box, const char *const headers[])
{
- struct index_mailbox *ibox = (struct index_mailbox *)box;
struct mail_cache_field *fields, header_field = {
NULL, 0, MAIL_CACHE_FIELD_HEADER, 0,
MAIL_CACHE_DECISION_TEMP
header_field.name = t_strconcat("hdr.", headers[i], NULL);
fields[i] = header_field;
}
- mail_cache_register_fields(ibox->cache, fields, count);
+ mail_cache_register_fields(box->cache, fields, count);
pool = pool_alloconly_create("index_header_lookup_ctx", 1024);
ctx = p_new(pool, struct index_header_lookup_ctx, 1);
parts = message_part_deserialize(mail->data_pool, part_buf->data,
part_buf->used, &error);
if (parts == NULL) {
- mail_cache_set_corrupted(mail->ibox->cache,
+ mail_cache_set_corrupted(mail->ibox->box.cache,
"Corrupted cached message_part data (%s)", error);
}
return parts;
if (mail->data.modseq != 0)
return mail->data.modseq;
- mail_index_modseq_enable(mail->ibox->index);
+ mail_index_modseq_enable(_mail->box->index);
mail->data.modseq =
mail_index_modseq_lookup(mail->trans->trans_view, _mail->seq);
return mail->data.modseq;
if (set->mail_cache_min_mail_count > 0) {
/* First check if we've configured caching not to be used with
low enough message count. */
- hdr = mail_index_get_header(mail->ibox->view);
+ hdr = mail_index_get_header(mail->ibox->box.view);
if (hdr->messages_count < set->mail_cache_min_mail_count)
return;
}
return;
}
- decision = mail_cache_field_get_decision(mail->ibox->cache,
+ decision = mail_cache_field_get_decision(mail->ibox->box.cache,
cache_field);
if (decision == (MAIL_CACHE_DECISION_NO | MAIL_CACHE_DECISION_FORCED)) {
/* we never want it cached */
/* normally don't cache both BODY and BODYSTRUCTURE, but do it
if BODY is forced to be cached */
- dec = mail_cache_field_get_decision(mail->ibox->cache,
+ dec = mail_cache_field_get_decision(mail->ibox->box.cache,
cache_field_body);
if (plain_bodystructure ||
(bodystructure_cached &&
array_create(&mail->mail.module_contexts, mail->mail.pool,
sizeof(void *), 5);
- mail->mail.v = *ibox->mail_vfuncs;
+ mail->mail.v = *ibox->box.mail_vfuncs;
mail->mail.mail.box = &ibox->box;
mail->mail.mail.transaction = &t->mailbox_ctx;
mail->mail.wanted_fields = wanted_fields;
mail->mail.wanted_headers = _wanted_headers;
- hdr = mail_index_get_header(ibox->view);
+ hdr = mail_index_get_header(ibox->box.view);
mail->uid_validity = hdr->uid_validity;
t->mail_ref_count++;
/* don't waste time doing full checks for all required
headers. assume that if we have "hdr.message-id" cached,
we don't need to parse the header. */
- cache_field_hdr = mail_cache_register_lookup(mail->ibox->cache,
+ cache_field_hdr = mail_cache_register_lookup(mail->ibox->box.cache,
"hdr.message-id");
if (cache_field_hdr == (unsigned int)-1 ||
mail_cache_field_exists(mail->trans->cache_view,
/* open the stream only if we didn't get here from
mailbox_save_init() */
- hdr = mail_index_get_header(mail->ibox->view);
+ hdr = mail_index_get_header(mail->ibox->box.view);
if (_mail->uid != 0 && _mail->uid < hdr->next_uid)
(void)mail_get_stream(_mail, NULL, NULL, &input);
}
struct index_mail *mail = (struct index_mail *)_mail;
uint32_t seq;
- if (mail_index_lookup_seq(mail->ibox->view, uid, &seq)) {
+ if (mail_index_lookup_seq(_mail->box->view, uid, &seq)) {
index_mail_set_seq(_mail, seq);
return TRUE;
} else {
mail_cache_transaction_reset(imail->trans->cache_trans);
imail->data.no_caching = TRUE;
imail->data.forced_no_caching = TRUE;
- mail_cache_set_corrupted(imail->ibox->cache,
+ mail_cache_set_corrupted(mail->box->cache,
"Broken %s for mail UID %u",
field_name, mail->uid);
}
int index_search_result_update_appends(struct mail_search_result *result,
unsigned int old_messages_count)
{
- struct index_mailbox *ibox = (struct index_mailbox *)result->box;
struct mailbox_transaction_context *t;
struct mail_search_context *search_ctx;
struct mail *mail;
uint32_t message_count;
int ret;
- message_count = mail_index_view_get_messages_count(ibox->view);
+ message_count = mail_index_view_get_messages_count(result->box->view);
if (old_messages_count == message_count) {
/* no new messages */
return 0;
void index_search_results_update_expunges(struct mailbox *box,
const ARRAY_TYPE(seq_range) *expunges)
{
- struct index_mailbox *ibox = (struct index_mailbox *)box;
const struct seq_range *seqs;
uint32_t seq, uid;
array_foreach(expunges, seqs) {
for (seq = seqs->seq1; seq <= seqs->seq2; seq++) {
- mail_index_lookup_uid(ibox->view, seq, &uid);
+ mail_index_lookup_uid(box->view, seq, &uid);
mailbox_search_results_remove(box, uid);
}
}
case SEARCH_KEYWORDS:
case SEARCH_MODSEQ:
if (arg->type == SEARCH_MODSEQ)
- mail_index_modseq_enable(ctx->ibox->index);
+ mail_index_modseq_enable(ctx->ibox->box.index);
ctx->have_index_args = TRUE;
break;
case SEARCH_ALL:
void index_sort_list_init_string(struct mail_search_sort_program *program)
{
- struct index_mailbox *ibox = (struct index_mailbox *)program->t->box;
struct sort_string_context *ctx;
const char *name;
ctx->reverse = (program->sort_program[0] & MAIL_SORT_FLAG_REVERSE) != 0;
ctx->program = program;
ctx->primary_sort_name = name;
- ctx->ext_id = mail_index_ext_register(ibox->index, name, 0,
+ ctx->ext_id = mail_index_ext_register(program->t->box->index, name, 0,
sizeof(uint32_t),
sizeof(uint32_t));
i_array_init(&ctx->zero_nodes, 128);
#include "mail-index-modseq.h"
static void
-index_storage_get_status_cache_fields(struct index_mailbox *ibox,
+index_storage_get_status_cache_fields(struct mailbox *box,
struct mailbox_status *status_r)
{
const struct mail_cache_field *fields;
ARRAY_TYPE(const_string) *cache_fields;
unsigned int i, count;
- fields = mail_cache_register_get_list(ibox->cache,
+ fields = mail_cache_register_get_list(box->cache,
pool_datastack_create(), &count);
/* a bit leaky to allocate memory from mailbox pool every time, but this
is unlikely to be called more than once for the mailbox anyway. */
- cache_fields = p_new(ibox->box.pool, ARRAY_TYPE(const_string), 1);
- p_array_init(cache_fields, ibox->box.pool, count);
+ cache_fields = p_new(box->pool, ARRAY_TYPE(const_string), 1);
+ p_array_init(cache_fields, box->pool, count);
for (i = 0; i < count; i++) {
dec = fields[i].decision & ~MAIL_CACHE_DECISION_FORCED;
if (dec != MAIL_CACHE_DECISION_NO)
memset(status_r, 0, sizeof(struct mailbox_status));
/* we can get most of the status items without any trouble */
- hdr = mail_index_get_header(ibox->view);
+ hdr = mail_index_get_header(box->view);
status_r->messages = hdr->messages_count;
if ((items & STATUS_RECENT) != 0) {
status_r->recent = index_mailbox_get_recent_count(ibox);
status_r->unseen = hdr->messages_count - hdr->seen_messages_count;
status_r->uidvalidity = hdr->uid_validity;
status_r->uidnext = hdr->next_uid;
- status_r->nonpermanent_modseqs = mail_index_is_in_memory(ibox->index);
+ status_r->nonpermanent_modseqs = mail_index_is_in_memory(box->index);
if ((items & STATUS_HIGHESTMODSEQ) != 0) {
status_r->highest_modseq =
- mail_index_modseq_get_highest(ibox->view);
+ mail_index_modseq_get_highest(box->view);
if (status_r->highest_modseq == 0) {
/* modseqs not enabled yet, but we can't return 0 */
status_r->highest_modseq = 1;
}
if ((items & STATUS_FIRST_UNSEEN_SEQ) != 0) {
- mail_index_lookup_first(ibox->view, 0, MAIL_SEEN,
+ mail_index_lookup_first(box->view, 0, MAIL_SEEN,
&status_r->first_unseen_seq);
}
if ((items & STATUS_KEYWORDS) != 0)
- status_r->keywords = mail_index_get_keywords(ibox->index);
+ status_r->keywords = mail_index_get_keywords(box->index);
if ((items & STATUS_CACHE_FIELDS) != 0)
- index_storage_get_status_cache_fields(ibox, status_r);
+ index_storage_get_status_cache_fields(box, status_r);
}
{
const struct mail_storage_settings *set = ibox->box.storage->set;
static bool initialized = FALSE;
- struct mail_cache *cache = ibox->cache;
+ struct mail_cache *cache = ibox->box.cache;
if (!initialized) {
initialized = TRUE;
ibox->index_flags &= ~MAIL_INDEX_OPEN_FLAG_CREATE;
if ((index_flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) != 0) {
- if (mail_index_is_in_memory(ibox->index)) {
+ if (mail_index_is_in_memory(box->index)) {
mail_storage_set_critical(box->storage,
"Couldn't create index file");
return -1;
return -1;
}
- ret = mail_index_open(ibox->index, index_flags, lock_method);
+ ret = mail_index_open(box->index, index_flags, lock_method);
if (ret <= 0 || ibox->move_to_memory) {
if ((index_flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) != 0) {
- mail_storage_set_index_error(ibox);
+ mail_storage_set_index_error(box);
return -1;
}
- if (mail_index_move_to_memory(ibox->index) < 0) {
+ if (mail_index_move_to_memory(box->index) < 0) {
/* try opening once more. it should be created
directly into memory now. */
- if (mail_index_open_or_create(ibox->index,
+ if (mail_index_open_or_create(box->index,
index_flags,
lock_method) < 0)
i_panic("in-memory index creation failed");
}
}
- ibox->cache = mail_index_get_cache(ibox->index);
+ box->cache = mail_index_get_cache(box->index);
index_cache_register_defaults(ibox);
- ibox->view = mail_index_view_open(ibox->index);
- ibox->keyword_names = mail_index_get_keywords(ibox->index);
+ box->view = mail_index_view_open(box->index);
+ ibox->keyword_names = mail_index_get_keywords(box->index);
- MODULE_CONTEXT_SET_FULL(ibox->view, mail_storage_mail_index_module,
- ibox, &ibox->view_module_ctx);
+ MODULE_CONTEXT_SET_FULL(box->view, mail_storage_mail_index_module,
+ box, &ibox->view_module_ctx);
box->opened = TRUE;
if (hook_mailbox_opened != NULL)
hook_mailbox_opened(box);
- if (mail_index_is_deleted(ibox->index)) {
+ if (mail_index_is_deleted(box->index)) {
mailbox_set_deleted(box);
return -1;
}
mail_storage_settings_to_index_flags(box->storage->set);
ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
- ibox->index = index_storage_alloc(box->list, name, flags, index_prefix);
+ box->index = index_storage_alloc(box->list, name, flags, index_prefix);
if (box->file_create_mode == 0)
mailbox_refresh_permissions(box);
- mail_index_set_permissions(ibox->index, box->file_create_mode,
+ mail_index_set_permissions(box->index, box->file_create_mode,
box->file_create_gid,
box->file_create_gid_origin);
}
int index_storage_mailbox_enable(struct mailbox *box,
enum mailbox_feature feature)
{
- struct index_mailbox *ibox = (struct index_mailbox *)box;
-
if ((feature & MAILBOX_FEATURE_CONDSTORE) != 0) {
box->enabled_features |= MAILBOX_FEATURE_CONDSTORE;
if (!box->opened) {
return -1;
}
T_BEGIN {
- mail_index_modseq_enable(ibox->index);
+ mail_index_modseq_enable(box->index);
} T_END;
}
return 0;
{
struct index_mailbox *ibox = (struct index_mailbox *) box;
- if (ibox->view != NULL)
- mail_index_view_close(&ibox->view);
+ if (box->view != NULL)
+ mail_index_view_close(&box->view);
index_mailbox_check_remove_all(ibox);
if (ibox->box.input != NULL)
i_stream_unref(&ibox->box.input);
- if (ibox->index != NULL)
- mail_index_alloc_cache_unref(ibox->index);
+ if (box->index != NULL)
+ mail_index_alloc_cache_unref(box->index);
if (array_is_created(&ibox->recent_flags))
array_free(&ibox->recent_flags);
i_free(ibox->cache_fields);
struct mail_cache_field field;
unsigned int i, j, old_count;
- old_fields = mail_cache_register_get_list(ibox->cache,
+ old_fields = mail_cache_register_get_list(ibox->box.cache,
pool_datastack_create(),
&old_count);
}
}
if (array_count(&new_fields) > 0) {
- mail_cache_register_fields(ibox->cache,
+ mail_cache_register_fields(ibox->box.cache,
array_idx_modifiable(&new_fields, 0),
array_count(&new_fields));
}
index_storage_mailbox_update_cache_fields(ibox, update);
/* make sure we get the latest index info */
- (void)mail_index_refresh(ibox->index);
- view = mail_index_view_open(ibox->index);
+ (void)mail_index_refresh(ibox->box.index);
+ view = mail_index_view_open(ibox->box.index);
hdr = mail_index_get_header(view);
trans = mail_index_transaction_begin(view,
bool index_storage_is_inconsistent(struct mailbox *box)
{
- struct index_mailbox *ibox = (struct index_mailbox *) box;
-
- return mail_index_view_is_inconsistent(ibox->view);
-}
-
-void mail_storage_set_index_error(struct index_mailbox *ibox)
-{
- if (mail_index_is_deleted(ibox->index))
- mailbox_set_deleted(&ibox->box);
- else
- mail_storage_set_internal_error(ibox->box.storage);
- mail_index_reset_error(ibox->index);
+ return mail_index_view_is_inconsistent(box->view);
}
bool index_keyword_is_valid(struct mailbox *box, const char *keyword,
unsigned int i, idx;
/* if it already exists, skip validity checks */
- if (mail_index_keyword_lookup(ibox->index, keyword, &idx))
+ if (mail_index_keyword_lookup(box->index, keyword, &idx))
return TRUE;
if (*keyword == '\0') {
array_append(&valid_keywords, keywords, 1);
}
(void)array_append_space(&valid_keywords); /* NULL-terminate */
- return mail_index_keywords_create(ibox->index, keywords);
+ return mail_index_keywords_create(ibox->box.index, keywords);
}
int index_keywords_create(struct mailbox *_box, const char *const keywords[],
return 0;
}
- *keywords_r = mail_index_keywords_create(ibox->index, keywords);
+ *keywords_r = mail_index_keywords_create(ibox->box.index, keywords);
return 0;
}
index_keywords_create_from_indexes(struct mailbox *_box,
const ARRAY_TYPE(keyword_indexes) *idx)
{
- struct index_mailbox *ibox = (struct index_mailbox *)_box;
-
- return mail_index_keywords_create_from_indexes(ibox->index, idx);
+ return mail_index_keywords_create_from_indexes(_box->index, idx);
}
void index_keywords_ref(struct mail_keywords *keywords)
struct mail_index_transaction_commit_result *result_r);
void (*save_rollback)(struct mail_save_context *save_ctx);
- struct mail_index *index;
- struct mail_index_view *view;
- struct mail_cache *cache;
- struct mail_vfuncs *mail_vfuncs;
-
struct timeout *notify_to, *notify_delay_to;
struct index_notify_file *notify_files;
struct index_notify_io *notify_ios;
unsigned int move_to_memory:1;
};
-void mail_storage_set_index_error(struct index_mailbox *ibox);
-
void index_storage_lock_notify(struct index_mailbox *ibox,
enum mailbox_lock_notify_type notify_type,
unsigned int secs_left);
array_foreach(changes, range) {
for (seq = range->seq1; seq <= range->seq2; seq++) {
- mail_index_lookup_uid(ctx->ibox->view, seq, &uid);
+ mail_index_lookup_uid(ctx->ibox->box.view, seq, &uid);
seq_range_array_add(&ctx->all_flag_update_uids, 0, uid);
}
}
if (!array_is_created(&ibox->recent_flags))
return 0;
- hdr = mail_index_get_header(ibox->view);
+ hdr = mail_index_get_header(ibox->box.view);
recent_count = ibox->recent_flags_count;
range = array_get(&ibox->recent_flags, &count);
for (i = count; i > 0; ) {
return;
for (; seq1 <= seq2; seq1++) {
- mail_index_lookup_uid(ibox->view, seq1, &uid);
+ mail_index_lookup_uid(ibox->box.view, seq1, &uid);
if (seq_range_array_remove(&ibox->recent_flags, uid))
ibox->recent_flags_count--;
}
while (mail_index_view_sync_next(ctx->sync_ctx, &sync_rec)) {
switch (sync_rec.type) {
case MAIL_INDEX_VIEW_SYNC_TYPE_FLAGS:
- if (!mail_index_lookup_seq_range(ctx->ibox->view,
+ if (!mail_index_lookup_seq_range(ctx->ibox->box.view,
sync_rec.uid1,
sync_rec.uid2,
&seq1, &seq2))
ctx->messages_count = 0;
} else {
ctx->messages_count =
- mail_index_view_get_messages_count(ibox->view);
+ mail_index_view_get_messages_count(box->view);
}
- ctx->sync_ctx = mail_index_view_sync_begin(ibox->view, sync_flags);
+ ctx->sync_ctx = mail_index_view_sync_begin(box->view, sync_flags);
if ((flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) == 0) {
mail_index_view_sync_get_expunges(ctx->sync_ctx,
&ctx->expunges);
index_mailbox_expunge_unseen_recent(struct index_mailbox_sync_context *ctx)
{
struct index_mailbox *ibox = ctx->ibox;
+ struct mail_index_view *view = ibox->box.view;
const struct mail_index_header *hdr;
uint32_t seq, start_uid, uid;
visible in this view, but append+expunge would be invisible.
recent_flags may however contain the append UID, so we'll have to
remove it separately */
- hdr = mail_index_get_header(ibox->view);
+ hdr = mail_index_get_header(view);
if (ctx->messages_count == 0)
uid = 0;
else if (ctx->messages_count <= hdr->messages_count)
- mail_index_lookup_uid(ibox->view, ctx->messages_count, &uid);
+ mail_index_lookup_uid(view, ctx->messages_count, &uid);
else {
- i_assert(mail_index_view_is_inconsistent(ibox->view));
+ i_assert(mail_index_view_is_inconsistent(view));
return;
}
for (seq = ctx->messages_count + 1; seq <= hdr->messages_count; seq++) {
start_uid = uid;
- mail_index_lookup_uid(ibox->view, seq, &uid);
+ mail_index_lookup_uid(view, seq, &uid);
if (start_uid + 1 > uid - 1)
continue;
hdr->next_uid - 1);
}
#ifdef DEBUG
- if (!mail_index_view_is_inconsistent(ibox->view)) {
+ if (!mail_index_view_is_inconsistent(view)) {
const struct seq_range *range;
unsigned int i, count;
for (uid = range[i].seq1; uid <= range[i].seq2; uid++) {
if (uid >= hdr->next_uid)
break;
- mail_index_lookup_seq(ibox->view, uid, &seq);
+ mail_index_lookup_seq(view, uid, &seq);
i_assert(seq != 0);
}
}
if (ctx->sync_ctx != NULL) {
if (mail_index_view_sync_commit(&ctx->sync_ctx,
&delayed_expunges) < 0) {
- mail_storage_set_index_error(ibox);
+ mail_storage_set_index_error(_ctx->box);
ret = -1;
}
}
index_mailbox_expunge_unseen_recent(ctx);
- if ((ibox->box.flags & MAILBOX_FLAG_KEEP_RECENT) != 0 &&
- ibox->box.opened) {
+ if ((_ctx->box->flags & MAILBOX_FLAG_KEEP_RECENT) != 0 &&
+ _ctx->box->opened) {
/* mailbox syncing didn't necessarily update our recent state */
- hdr = mail_index_get_header(ibox->view);
+ hdr = mail_index_get_header(_ctx->box->view);
if (hdr->first_recent_uid > ibox->recent_flags_prev_uid) {
- mail_index_lookup_seq_range(ibox->view,
+ mail_index_lookup_seq_range(_ctx->box->view,
hdr->first_recent_uid,
hdr->next_uid,
&seq1, &seq2);
if (seq1 != 0) {
- index_mailbox_set_recent_seq(ibox, ibox->view,
+ index_mailbox_set_recent_seq(ibox,
+ _ctx->box->view,
seq1, seq2);
}
}
if (tbox->strmap_view == NULL) {
/* first time we're threading this mailbox */
- struct index_mailbox *ibox = (struct index_mailbox *)ctx->box;
-
tbox->strmap_view =
- mail_index_strmap_view_open(tbox->strmap, ibox->view,
+ mail_index_strmap_view_open(tbox->strmap,
+ ctx->box->view,
mail_thread_hash_key_cmp,
mail_thread_hash_rec_cmp,
mail_thread_strmap_remap,
tbox->module_ctx.super = box->v;
box->v.close = mail_thread_mailbox_close;
- tbox->strmap = mail_index_strmap_init(ibox->index,
+ tbox->strmap = mail_index_strmap_init(box->index,
MAIL_THREAD_INDEX_SUFFIX);
tbox->next_msgid_idx = 1;
it->super.rollback(it->trans);
else {
if (it->super.commit(it->trans, result_r) < 0) {
- mail_storage_set_index_error(ibox);
+ mail_storage_set_index_error(t->box);
ret = -1;
}
}
struct mailbox *box,
enum mailbox_transaction_flags flags)
{
- struct index_mailbox *ibox = (struct index_mailbox *)box;
enum mail_index_transaction_flags trans_flags;
i_assert(box->opened);
if ((flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0)
trans_flags |= MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL;
if ((flags & MAILBOX_TRANSACTION_FLAG_REFRESH) != 0)
- (void)mail_index_refresh(ibox->index);
+ (void)mail_index_refresh(box->index);
- it->trans = mail_index_transaction_begin(ibox->view, trans_flags);
- it->mailbox_ctx.box = &ibox->box;
+ it->trans = mail_index_transaction_begin(box->view, trans_flags);
+ it->mailbox_ctx.box = box;
array_create(&it->mailbox_ctx.module_contexts, default_pool,
sizeof(void *), 5);
it->trans_view = mail_index_transaction_open_updated_view(it->trans);
- it->cache_view = mail_cache_view_open(ibox->cache, it->trans_view);
+ it->cache_view = mail_cache_view_open(box->cache, it->trans_view);
it->cache_trans = mail_cache_get_transaction(it->cache_view, it->trans);
/* set up after mail_cache_get_transaction(), so that we'll still
{
struct index_transaction_context *t =
(struct index_transaction_context *)_t;
+ struct mailbox *box = _t->box;
struct mail_index_transaction *itrans = t->trans;
- struct index_mailbox *ibox = (struct index_mailbox *)_t->box;
struct mail_index_transaction_commit_result result;
int ret;
_t->changes = changes_r;
ret = mail_index_transaction_commit_full(&itrans, &result);
- if (ret < 0 && mail_index_is_deleted(ibox->index))
- mailbox_set_deleted(&ibox->box);
+ if (ret < 0 && mail_index_is_deleted(_t->box->index))
+ mailbox_set_deleted(_t->box);
changes_r->ignored_uid_changes = result.ignored_uid_changes;
changes_r->ignored_modseq_changes = result.ignored_modseq_changes;
- i_assert(ibox->box.transaction_count > 0 ||
- ibox->view->transactions == 0);
+ i_assert(box->transaction_count > 0 ||
+ box->view->transactions == 0);
return ret;
}
{
struct index_transaction_context *t =
(struct index_transaction_context *)_t;
+ struct mailbox *box = _t->box;
struct mail_index_transaction *itrans = t->trans;
- struct index_mailbox *ibox = (struct index_mailbox *)_t->box;
mail_index_transaction_rollback(&itrans);
- i_assert(ibox->box.transaction_count > 0 ||
- ibox->view->transactions == 0);
+ i_assert(box->transaction_count > 0 ||
+ box->view->transactions == 0);
}
void index_transaction_set_max_modseq(struct mailbox_transaction_context *_t,
return 0;
}
- if (mail_index_is_deleted(dest_mbox->ibox.index)) {
+ if (mail_index_is_deleted(dest_mbox->ibox.box.index)) {
mailbox_set_deleted(&dest_mbox->ibox.box);
return -1;
}
/* one reason this could happen is if we delayed opening
dovecot-uidlist and we're trying to open a mail that got recently
expunged. Let's test this theory first: */
- (void)mail_index_refresh(mbox->ibox.index);
- view = mail_index_view_open(mbox->ibox.index);
+ (void)mail_index_refresh(mbox->ibox.box.index);
+ view = mail_index_view_open(mbox->ibox.box.index);
exists = mail_index_lookup_seq(view, mail->uid, &seq);
mail_index_view_close(&view);
psize_idx = mail->ibox->cache_fields[MAIL_CACHE_PHYSICAL_FULL_SIZE].idx;
vsize_idx = mail->ibox->cache_fields[MAIL_CACHE_VIRTUAL_FULL_SIZE].idx;
if (not_pop3_only) {
- vsize_dec = mail_cache_field_get_decision(mail->ibox->cache,
+ vsize_dec = mail_cache_field_get_decision(mail->ibox->box.cache,
vsize_idx);
vsize_dec &= ~MAIL_CACHE_DECISION_FORCED;
} else {
/* also check if there are any non-[pv]size cached fields */
vsize_dec = MAIL_CACHE_DECISION_NO;
- fields = mail_cache_register_get_list(mail->ibox->cache,
+ fields = mail_cache_register_get_list(mail->ibox->box.cache,
pool_datastack_create(),
&count);
for (i = 0; i < count; i++) {
including to the uidlist if it's already in filename.
do some extra checks here to catch potential cache bugs. */
if (vsize && mail->data.virtual_size != size) {
- mail_cache_set_corrupted(mail->ibox->cache,
+ mail_cache_set_corrupted(mail->ibox->box.cache,
"Corrupted virtual size for uid=%u: "
"%"PRIuUOFF_T" != %"PRIuUOFF_T,
mail->mail.mail.uid,
mail->data.virtual_size, size);
mail->data.virtual_size = size;
} else if (!vsize && mail->data.physical_size != size) {
- mail_cache_set_corrupted(mail->ibox->cache,
+ mail_cache_set_corrupted(mail->ibox->box.cache,
"Corrupted physical size for uid=%u: "
"%"PRIuUOFF_T" != %"PRIuUOFF_T,
mail->mail.mail.uid,
string_t *path;
int fd;
- if (mail_index_is_deleted(mbox->ibox.index)) {
+ if (mail_index_is_deleted(mbox->ibox.box.index)) {
mailbox_set_deleted(box);
return -1;
}
if (ret < 0) {
ctx->keywords_sync_ctx = !ctx->have_keywords ? NULL :
maildir_keywords_sync_init(ctx->mbox->keywords,
- ctx->mbox->ibox.index);
+ ctx->mbox->ibox.box.index);
/* unlink the files we just moved in an attempt to rollback
the transaction. uidlist is still locked, so at least other
mbox->ibox.box.pool = pool;
mbox->ibox.box.storage = storage;
mbox->ibox.box.list = list;
- mbox->ibox.mail_vfuncs = &maildir_mail_vfuncs;
+ mbox->ibox.box.mail_vfuncs = &maildir_mail_vfuncs;
mbox->ibox.save_commit_pre = maildir_transaction_save_commit_pre;
mbox->ibox.save_commit_post = maildir_transaction_save_commit_post;
mbox->storage = (struct maildir_storage *)storage;
mbox->maildir_ext_id =
- mail_index_ext_register(mbox->ibox.index, "maildir",
+ mail_index_ext_register(mbox->ibox.box.index, "maildir",
sizeof(mbox->maildir_hdr), 0, 0);
mbox->uidlist = maildir_uidlist_init(mbox);
mbox->keywords = maildir_keywords_init(mbox);
struct maildir_sync_context *maildir_sync_ctx,
struct maildir_index_sync_context **ctx_r)
{
+ struct mailbox *_box = &mbox->ibox.box;
struct maildir_index_sync_context *ctx;
struct mail_index_sync_ctx *sync_ctx;
struct mail_index_view *view;
sync_flags = 0;
/* don't drop recent messages if we're saving messages */
- if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0 &&
+ if ((_box->flags & MAILBOX_FLAG_KEEP_RECENT) == 0 &&
maildir_sync_ctx != NULL)
sync_flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
- if (mail_index_sync_begin(mbox->ibox.index, &sync_ctx, &view, &trans,
- sync_flags) < 0) {
- mail_storage_set_index_error(&mbox->ibox);
+ if (mail_index_sync_begin(_box->index, &sync_ctx, &view,
+ &trans, sync_flags) < 0) {
+ mail_storage_set_index_error(_box);
return -1;
}
ctx->view = view;
ctx->trans = trans;
ctx->keywords_sync_ctx =
- maildir_keywords_sync_init(mbox->keywords, mbox->ibox.index);
+ maildir_keywords_sync_init(mbox->keywords, _box->index);
ctx->sync_changes =
index_sync_changes_init(&mbox->ibox, ctx->sync_ctx,
ctx->view, ctx->trans,
mbox->maildir_hdr.cur_mtime_nsecs = ST_MTIME_NSEC(st);
}
- mail_index_get_header_ext(mbox->ibox.view, mbox->maildir_ext_id,
+ mail_index_get_header_ext(mbox->ibox.box.view, mbox->maildir_ext_id,
&data, &data_size);
if (data_size != sizeof(mbox->maildir_hdr) ||
maildir_index_header_has_changed(data, &mbox->maildir_hdr)) {
start a second index sync and crash. */
mbox->syncing_commit = TRUE;
if (mail_index_sync_commit(&ctx->sync_ctx) < 0) {
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(&mbox->ibox.box);
ret = -1;
}
mbox->syncing_commit = FALSE;
static void
maildir_sync_mail_keywords(struct maildir_index_sync_context *ctx, uint32_t seq)
{
- struct maildir_mailbox *mbox = ctx->mbox;
+ struct mailbox *box = &ctx->mbox->ibox.box;
struct mail_keywords *kw;
unsigned int i, j, old_count, new_count;
const unsigned int *old_indexes, *new_indexes;
if (!have_indexonly_keywords) {
/* no index-only keywords found, so something changed.
just replace them all. */
- kw = mail_index_keywords_create_from_indexes(mbox->ibox.index,
+ kw = mail_index_keywords_create_from_indexes(box->index,
&ctx->keywords);
mail_index_update_keywords(ctx->trans, seq, MODIFY_REPLACE, kw);
mail_index_keywords_unref(&kw);
}
if (array_count(&ctx->idx_keywords) > 0) {
- kw = mail_index_keywords_create_from_indexes(mbox->ibox.index,
+ kw = mail_index_keywords_create_from_indexes(box->index,
&ctx->idx_keywords);
mail_index_update_keywords(ctx->trans, seq, MODIFY_REMOVE, kw);
mail_index_keywords_unref(&kw);
}
if (array_count(&ctx->keywords) > 0) {
- kw = mail_index_keywords_create_from_indexes(mbox->ibox.index,
+ kw = mail_index_keywords_create_from_indexes(box->index,
&ctx->keywords);
mail_index_update_keywords(ctx->trans, seq, MODIFY_ADD, kw);
mail_index_keywords_unref(&kw);
struct mail_keywords *kw;
kw = mail_index_keywords_create_from_indexes(
- mbox->ibox.index, &ctx->keywords);
+ mbox->ibox.box.index, &ctx->keywords);
mail_index_update_keywords(trans, seq,
MODIFY_REPLACE, kw);
mail_index_keywords_unref(&kw);
const void *data;
size_t data_size;
- if (mail_index_refresh(mbox->ibox.index) < 0) {
- mail_storage_set_index_error(&mbox->ibox);
+ if (mail_index_refresh(mbox->ibox.box.index) < 0) {
+ mail_storage_set_index_error(&mbox->ibox.box);
return -1;
}
- mail_index_get_header_ext(mbox->ibox.view, mbox->maildir_ext_id,
+ mail_index_get_header_ext(mbox->ibox.box.view, mbox->maildir_ext_id,
&data, &data_size);
if (data_size == 0) {
/* doesn't exist */
const struct mail_index_header *hdr;
uint32_t uid_validity, next_uid;
- hdr = mail_index_get_header(mbox->ibox.view);
+ hdr = mail_index_get_header(mbox->ibox.box.view);
if (hdr->uid_validity == 0)
return;
/* if there are files in new/, we'll need to move them. we'll check
this by checking if we have any recent messages */
- hdr = mail_index_get_header(ctx->mbox->ibox.view);
+ hdr = mail_index_get_header(ctx->mbox->ibox.box.view);
return hdr->first_recent_uid <
maildir_uidlist_get_next_uid(ctx->mbox->uidlist);
}
if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
- return mail_index_sync_have_any(mbox->ibox.index, flags) ? 1 : 0;
+ return mail_index_sync_have_any(mbox->ibox.box.index, flags) ? 1 : 0;
}
static int maildir_sync_context(struct maildir_sync_context *ctx, bool forced,
if (mbox->flags_view == NULL) {
mbox->flags_view =
- mail_index_view_open(mbox->ibox.index);
+ mail_index_view_open(mbox->ibox.box.index);
}
sync_ctx = mail_index_view_sync_begin(mbox->flags_view,
MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT);
if (mail_index_view_sync_commit(&sync_ctx, &b) < 0) {
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(&mbox->ibox.box);
ret = -1;
}
/* make sure the map stays in private memory */
int maildir_uidlist_refresh_fast_init(struct maildir_uidlist *uidlist)
{
const struct maildir_index_header *mhdr = &uidlist->mbox->maildir_hdr;
- struct mail_index *index = uidlist->mbox->ibox.index;
+ struct mail_index *index = uidlist->mbox->ibox.box.index;
struct mail_index_view *view;
const struct mail_index_header *hdr;
struct stat st;
const struct mail_index_header *hdr;
if (uidlist->ibox->box.opened) {
- hdr = mail_index_get_header(uidlist->ibox->view);
+ hdr = mail_index_get_header(uidlist->ibox->box.view);
if (hdr->uid_validity != 0) {
uidlist->uid_validity = hdr->uid_validity;
return;
if (!uidlist->mbox->ibox.box.opened)
return;
- mail_index_refresh(uidlist->mbox->ibox.index);
- view = mail_index_view_open(uidlist->mbox->ibox.index);
+ mail_index_refresh(uidlist->mbox->ibox.box.index);
+ view = mail_index_view_open(uidlist->mbox->ibox.box.index);
count = array_count(&uidlist->records);
hdr = mail_index_get_header(view);
if (count * UIDLIST_COMPRESS_PERCENTAGE / 100 <= hdr->messages_count) {
static bool maildir_uidlist_want_compress(struct maildir_uidlist_sync_ctx *ctx)
{
- struct mail_index_view *view = ctx->uidlist->mbox->ibox.view;
+ struct mail_index_view *view = ctx->uidlist->mbox->ibox.box.view;
unsigned int min_rewrite_count, messages_count;
if (!ctx->uidlist->locked_refresh)
} else {
*have_flags_r = TRUE;
kw_ctx = maildir_keywords_sync_init_readonly(mbox->keywords,
- mbox->ibox.index);
+ mbox->ibox.box.index);
fname = maildir_filename_set_flags(kw_ctx, fname,
flags, &keywords);
maildir_keywords_sync_deinit(&kw_ctx);
i_assert(lock_type == F_RDLCK || mbox->mbox_lock_type != F_RDLCK);
/* mbox must be locked before index */
- i_assert(mbox->ibox.index->lock_type != F_WRLCK);
+ i_assert(mbox->ibox.box.index->lock_type != F_WRLCK);
if (mbox->mbox_lock_type == F_UNLCK) {
ret = mbox_update_locking(mbox, lock_type, &fcntl_locked);
/* refresh index file after mbox has been locked to
make sure we get only up-to-date mbox offsets. */
- if (mail_index_refresh(mbox->ibox.index) < 0) {
- mail_storage_set_index_error(&mbox->ibox);
+ if (mail_index_refresh(mbox->ibox.box.index) < 0) {
+ mail_storage_set_index_error(&mbox->ibox.box);
return -1;
}
if (mbox_sync_header_refresh(mbox) < 0)
return -1;
- view = mail_index_view_open(mail->ibox->index);
+ view = mail_index_view_open(mail->ibox->box.index);
hdr = mail_index_get_header(view);
if (!mail_index_lookup_seq(view, mail->mail.mail.uid, &seq))
i_panic("Message unexpectedly expunged from index");
/* open a new view to get the header. this is required if we just
synced the mailbox so we can get updated next_uid. */
- (void)mail_index_refresh(mbox->ibox.index);
- view = mail_index_view_open(mbox->ibox.index);
+ (void)mail_index_refresh(mbox->ibox.box.index);
+ view = mail_index_view_open(mbox->ibox.box.index);
hdr = mail_index_get_header(view);
ctx->next_uid = hdr->next_uid;
const char *const *keyword_names;
unsigned int i, count, keyword_names_count;
- keyword_names_list = mail_index_get_keywords(ctx->mbox->ibox.index);
+ keyword_names_list = mail_index_get_keywords(ctx->mbox->ibox.box.index);
keyword_names = array_get(keyword_names_list, &keyword_names_count);
str_append(ctx->headers, "X-Keywords:");
return -1;
}
- if (mail_index_is_deleted(mbox->ibox.index)) {
+ if (mail_index_is_deleted(mbox->ibox.box.index)) {
mailbox_set_deleted(&mbox->ibox.box);
return -1;
}
mbox->ibox.box.pool = pool;
mbox->ibox.box.storage = storage;
mbox->ibox.box.list = list;
- mbox->ibox.mail_vfuncs = &mbox_mail_vfuncs;
+ mbox->ibox.box.mail_vfuncs = &mbox_mail_vfuncs;
mbox->ibox.save_commit_pre = mbox_transaction_save_commit_pre;
mbox->ibox.save_commit_post = mbox_transaction_save_commit_post;
mbox->mbox_fd = -1;
mbox->mbox_lock_type = F_UNLCK;
mbox->mbox_ext_idx =
- mail_index_ext_register(mbox->ibox.index, "mbox",
+ mail_index_ext_register(mbox->ibox.box.index, "mbox",
sizeof(mbox->mbox_hdr),
sizeof(uint64_t), sizeof(uint64_t));
mbox->md5hdr_ext_idx =
- mail_index_ext_register(mbox->ibox.index, "header-md5",
+ mail_index_ext_register(mbox->ibox.box.index, "header-md5",
0, 16, 1);
if ((storage->flags & MAIL_STORAGE_FLAG_KEEP_HEADER_MD5) != 0)
sync_flags |= MBOX_SYNC_UNDIRTY | MBOX_SYNC_FORCE_SYNC;
}
- if (mbox->ibox.view != NULL) {
- hdr = mail_index_get_header(mbox->ibox.view);
+ if (box->view != NULL) {
+ hdr = mail_index_get_header(box->view);
if ((hdr->flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0 &&
!mbox->ibox.backend_readonly) {
/* we've done changes to mbox which haven't been
parse_imap_keywords_list(struct mbox_sync_mail_context *ctx,
struct message_header_line *hdr, size_t pos)
{
+ struct mailbox *box = &ctx->sync_ctx->mbox->ibox.box;
const char *keyword, *error;
size_t keyword_start;
unsigned int idx, count;
pos - keyword_start);
if (mailbox_keyword_is_valid(&ctx->sync_ctx->mbox->ibox.box,
keyword, &error)) {
- mail_index_keyword_lookup_or_create(
- ctx->sync_ctx->mbox->ibox.index, keyword, &idx);
+ mail_index_keyword_lookup_or_create(box->index,
+ keyword, &idx);
}
count++;
}
static bool parse_x_keywords_real(struct mbox_sync_mail_context *ctx,
struct message_header_line *hdr)
{
+ struct mailbox *box = &ctx->sync_ctx->mbox->ibox.box;
ARRAY_TYPE(keyword_indexes) keyword_list;
const unsigned int *list;
string_t *keyword;
str_truncate(keyword, 0);
str_append_n(keyword, hdr->full_value + keyword_start,
pos - keyword_start);
- if (!mail_index_keyword_lookup(ctx->sync_ctx->mbox->ibox.index,
- str_c(keyword), &idx)) {
+ if (!mail_index_keyword_lookup(box->index, str_c(keyword),
+ &idx)) {
/* keyword wasn't found. that means the sent mail
originally contained X-Keywords header. Delete it. */
return FALSE;
static void
mbox_sync_update_index_keywords(struct mbox_sync_mail_context *mail_ctx)
{
- struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
+ struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
+ struct mail_index *index = sync_ctx->mbox->ibox.box.index;
struct mail_keywords *keywords;
keywords = !array_is_created(&mail_ctx->mail.keywords) ?
- mail_index_keywords_create(sync_ctx->mbox->ibox.index, NULL) :
- mail_index_keywords_create_from_indexes(
- sync_ctx->mbox->ibox.index, &mail_ctx->mail.keywords);
+ mail_index_keywords_create(index, NULL) :
+ mail_index_keywords_create_from_indexes(index,
+ &mail_ctx->mail.keywords);
mail_index_update_keywords(sync_ctx->t, sync_ctx->idx_seq,
MODIFY_REPLACE, keywords);
mail_index_keywords_unref(&keywords);
mail_generate_guid_128(mbox->mbox_hdr.mailbox_guid);
}
- mail_index_get_header_ext(mbox->ibox.view, mbox->mbox_ext_idx,
+ mail_index_get_header_ext(mbox->ibox.box.view, mbox->mbox_ext_idx,
&data, &data_size);
if (data_size != sizeof(mbox->mbox_hdr) ||
memcmp(data, &mbox->mbox_hdr, data_size) != 0) {
const void *data;
size_t data_size;
- if (mail_index_refresh(mbox->ibox.index) < 0) {
- mail_storage_set_index_error(&mbox->ibox);
+ if (mail_index_refresh(mbox->ibox.box.index) < 0) {
+ mail_storage_set_index_error(&mbox->ibox.box);
return -1;
}
- mail_index_get_header_ext(mbox->ibox.view, mbox->mbox_ext_idx,
+ mail_index_get_header_ext(mbox->ibox.box.view, mbox->mbox_ext_idx,
&data, &data_size);
if (data_size == 0) {
/* doesn't exist. FIXME: backwards compatibility copying */
- hdr = mail_index_get_header(mbox->ibox.view);
+ hdr = mail_index_get_header(mbox->ibox.box.view);
mbox->mbox_hdr.sync_mtime = hdr->sync_stamp;
mbox->mbox_hdr.sync_size = hdr->sync_size;
return 0;
if ((flags & MBOX_SYNC_REWRITE) != 0)
sync_flags |= MAIL_INDEX_SYNC_FLAG_FLUSH_DIRTY;
- ret = mail_index_sync_begin(mbox->ibox.index, &index_sync_ctx,
+ ret = mail_index_sync_begin(mbox->ibox.box.index, &index_sync_ctx,
&sync_view, &trans, sync_flags);
if (ret <= 0) {
if (ret < 0)
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(&mbox->ibox.box);
return ret;
}
/* index may need to do internal syncing though, so commit
instead of rollbacking. */
if (mail_index_sync_commit(&index_sync_ctx) < 0) {
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(&mbox->ibox.box);
return -1;
}
return 0;
pool_alloconly_create("mbox saved keywords", 4096);
/* make sure we've read the latest keywords in index */
- (void)mail_index_get_keywords(mbox->ibox.index);
+ (void)mail_index_get_keywords(mbox->ibox.box.index);
i_array_init(&sync_ctx.mails, 64);
if (ret < 0)
mail_index_sync_rollback(&index_sync_ctx);
else if (mail_index_sync_commit(&index_sync_ctx) < 0) {
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(&mbox->ibox.box);
ret = -1;
}
sync_ctx.t = NULL;
mbox->ibox.box.pool = pool;
mbox->ibox.box.storage = storage;
mbox->ibox.box.list = list;
- mbox->ibox.mail_vfuncs = &raw_mail_vfuncs;
+ mbox->ibox.box.mail_vfuncs = &raw_mail_vfuncs;
index_storage_mailbox_alloc(&mbox->ibox, name, input, flags, NULL);
if ((mbox->ibox.box.flags & MAILBOX_FLAG_KEEP_RECENT) == 0)
sync_flags |= MAIL_INDEX_SYNC_FLAG_DROP_RECENT;
- ret = mail_index_sync_begin(mbox->ibox.index, &index_sync_ctx,
+ ret = mail_index_sync_begin(mbox->ibox.box.index, &index_sync_ctx,
&sync_view, &trans, sync_flags);
if (ret <= 0) {
if (ret < 0)
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(&mbox->ibox.box);
return ret;
}
index_mailbox_set_recent_uid(&mbox->ibox, 1);
if (mail_index_sync_commit(&index_sync_ctx) < 0) {
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(&mbox->ibox.box);
return -1;
}
mbox->synced = TRUE;
uint64_t modseq;
ibox = t_new(struct index_mailbox, 1);
- ibox->index = t_new(struct mail_index, 1);
- ibox->view = t_new(struct mail_index_view, 1);
+ ibox->box.index = t_new(struct mail_index, 1);
+ ibox->box.view = t_new(struct mail_index_view, 1);
- ibox->view->log_file_head_seq = 101;
- ibox->view->log_file_head_offset = 1024;
+ ibox->box.view->log_file_head_seq = 101;
+ ibox->box.view->log_file_head_offset = 1024;
test_begin("index storage get expunges");
/* private: */
pool_t pool;
+ struct mail_index *index;
+ struct mail_index_view *view;
+ struct mail_cache *cache;
+
+ /* default vfuncs for new struct mails. */
+ const struct mail_vfuncs *mail_vfuncs;
+
/* mailbox's MAILBOX_LIST_PATH_TYPE_MAILBOX */
const char *path;
/* mailbox's virtual name (from mail_namespace_get_vname()) */
void mail_storage_set_critical(struct mail_storage *storage,
const char *fmt, ...) ATTR_FORMAT(2, 3);
void mail_storage_set_internal_error(struct mail_storage *storage);
+void mail_storage_set_index_error(struct mailbox *box);
bool mail_storage_set_error_from_errno(struct mail_storage *storage);
int mail_set_aborted(struct mail *mail);
}
}
+void mail_storage_set_index_error(struct mailbox *box)
+{
+ if (mail_index_is_deleted(box->index))
+ mailbox_set_deleted(box);
+ else
+ mail_storage_set_internal_error(box->storage);
+ mail_index_reset_error(box->index);
+}
+
const struct mail_storage_settings *
mail_storage_get_settings(struct mail_storage *storage)
{
const void *data;
bool expunged;
- mail_index_lookup_ext(mbox->ibox.view, seq, mbox->virtual_ext_id,
+ mail_index_lookup_ext(mail->box->view, seq, mbox->virtual_ext_id,
&data, &expunged);
vrec = data;
vmail->imail.data.seq = seq;
mail->seq = seq;
- mail_index_lookup_uid(mbox->ibox.view, seq, &mail->uid);
+ mail_index_lookup_uid(mail->box->view, seq, &mail->uid);
if (!vmail->lost) {
mail->expunged = vmail->backend_mail->expunged;
static bool virtual_mail_set_uid(struct mail *mail, uint32_t uid)
{
- struct virtual_mailbox *mbox = (struct virtual_mailbox *)mail->box;
uint32_t seq;
- if (!mail_index_lookup_seq(mbox->ibox.view, uid, &seq))
+ if (!mail_index_lookup_seq(mail->box->view, uid, &seq))
return FALSE;
virtual_mail_set_seq(mail, seq);
seq_range_array_add(&vctx->result, 0, ctx->seq);
} else {
/* possible match, save and check later */
- mail_index_lookup_ext(mbox->ibox.view, ctx->seq,
+ mail_index_lookup_ext(mbox->ibox.box.view, ctx->seq,
mbox->virtual_ext_id,
&data, &expunged);
vrec = data;
mbox->ibox.box.pool = pool;
mbox->ibox.box.storage = _storage;
mbox->ibox.box.list = list;
- mbox->ibox.mail_vfuncs = &virtual_mail_vfuncs;
+ mbox->ibox.box.mail_vfuncs = &virtual_mail_vfuncs;
index_storage_mailbox_alloc(&mbox->ibox, name, input, flags,
VIRTUAL_INDEX_PREFIX);
mbox->vseq_lookup_prev_mailbox = i_strdup("");
mbox->virtual_ext_id =
- mail_index_ext_register(mbox->ibox.index, "virtual", 0,
+ mail_index_ext_register(mbox->ibox.box.index, "virtual", 0,
sizeof(struct virtual_mail_index_record),
sizeof(uint32_t));
return &mbox->ibox.box;
struct virtual_backend_box *bbox,
struct mail_search_result *result)
{
- struct index_mailbox *ibox = (struct index_mailbox *)bbox->box;
const struct virtual_mail_index_record *vrec;
struct virtual_backend_uidmap uidmap;
const void *data;
uidmap.virtual_uid = vuid;
array_append(&bbox->uids, &uidmap, 1);
- if (mail_index_lookup_seq(ibox->view, vrec->real_uid,
- &seq)) {
+ if (mail_index_lookup_seq(bbox->box->view,
+ vrec->real_uid, &seq)) {
seq_range_array_add(&result->uids, 0,
vrec->real_uid);
} else {
const enum mailbox_search_result_flags result_flags =
MAILBOX_SEARCH_RESULT_FLAG_UPDATE |
MAILBOX_SEARCH_RESULT_FLAG_QUEUE_SYNC;
- struct index_mailbox *ibox = (struct index_mailbox *)bbox->box;
+ struct mail_index_view *view = bbox->box->view;
struct mail_search_result *result;
ARRAY_TYPE(seq_range) removed_uids, added_uids, flag_update_uids;
uint64_t modseq, old_highest_modseq;
virtual index), based on modseq changes. (we'll assume all modseq
changes are due to flag changes, which may not be true in future) */
if (bbox->sync_next_uid <= 1 ||
- !mail_index_lookup_seq_range(ibox->view, 1, bbox->sync_next_uid-1,
+ !mail_index_lookup_seq_range(view, 1, bbox->sync_next_uid-1,
&seq, &old_msg_count))
old_msg_count = 0;
- old_highest_modseq = mail_index_modseq_get_highest(ibox->view);
+ old_highest_modseq = mail_index_modseq_get_highest(view);
t_array_init(&flag_update_uids, I_MIN(128, old_msg_count));
if (bbox->sync_highest_modseq < old_highest_modseq) {
for (seq = 1; seq <= old_msg_count; seq++) {
- modseq = mail_index_modseq_lookup(ibox->view, seq);
+ modseq = mail_index_modseq_lookup(view, seq);
if (modseq > bbox->sync_highest_modseq) {
- mail_index_lookup_uid(ibox->view, seq, &uid);
+ mail_index_lookup_uid(view, seq, &uid);
seq_range_array_add(&flag_update_uids, 0, uid);
}
}
unsigned int *idx1_r,
unsigned int *idx2_r)
{
- struct index_mailbox *ibox = (struct index_mailbox *)bbox->box;
const struct virtual_backend_uidmap *uidmap;
unsigned int idx, count;
uint32_t uid1, uid2;
- mail_index_lookup_uid(ibox->view, sync_rec->seq1, &uid1);
- mail_index_lookup_uid(ibox->view, sync_rec->seq2, &uid2);
+ mail_index_lookup_uid(bbox->box->view, sync_rec->seq1, &uid1);
+ mail_index_lookup_uid(bbox->box->view, sync_rec->seq2, &uid2);
(void)array_bsearch_insert_pos(&bbox->uids, &uid1,
virtual_backend_uidmap_bsearch_cmp,
&idx);
struct virtual_backend_box *bbox,
const struct mailbox_sync_rec *sync_rec)
{
- struct index_mailbox *ibox = (struct index_mailbox *)bbox->box;
struct virtual_backend_uidmap *uidmap;
uint32_t uid1, uid2;
unsigned int i, idx1, count;
- mail_index_lookup_uid(ibox->view, sync_rec->seq1, &uid1);
- mail_index_lookup_uid(ibox->view, sync_rec->seq2, &uid2);
+ mail_index_lookup_uid(bbox->box->view, sync_rec->seq1, &uid1);
+ mail_index_lookup_uid(bbox->box->view, sync_rec->seq2, &uid2);
/* remember only the expunges for messages that
already exist for this mailbox */
static int virtual_sync_backend_box(struct virtual_sync_context *ctx,
struct virtual_backend_box *bbox)
{
- struct index_mailbox *ibox = (struct index_mailbox *)bbox->box;
enum mailbox_sync_flags sync_flags;
struct mailbox_status status;
int ret;
virtual_backend_box_sync_mail_unset(bbox);
/* we use modseqs for speeding up initial search result build.
make sure the backend has them enabled. */
- mail_index_modseq_enable(ibox->index);
+ mail_index_modseq_enable(bbox->box->index);
sync_flags = ctx->flags & (MAILBOX_SYNC_FLAG_FULL_READ |
MAILBOX_SYNC_FLAG_FULL_WRITE |
seq_range_array_iter_init(&iter, isync_ctx->expunges);
while (seq_range_array_iter_nth(&iter, n++, &seq)) {
- mail_index_lookup_ext(mbox->ibox.view, seq,
+ mail_index_lookup_ext(mbox->ibox.box.view, seq,
mbox->virtual_ext_id, &data, &expunged);
vrec = data;
virtual_sync_backend_boxes_finish(ctx);
if (success) {
if (mail_index_sync_commit(&ctx->index_sync_ctx) < 0) {
- mail_storage_set_index_error(&ctx->mbox->ibox);
+ mail_storage_set_index_error(&ctx->mbox->ibox.box);
ret = -1;
}
} else {
ctx = i_new(struct virtual_sync_context, 1);
ctx->mbox = mbox;
ctx->flags = flags;
- ctx->index = mbox->ibox.index;
+ ctx->index = mbox->ibox.box.index;
/* Removed messages are expunged when
a) EXPUNGE is used
b) Mailbox is being opened (FIX_INCONSISTENT is set) */
index_sync_flags);
if (ret <= 0) {
if (ret < 0)
- mail_storage_set_index_error(&mbox->ibox);
+ mail_storage_set_index_error(&mbox->ibox.box);
i_free(ctx);
return ret;
}