From: Timo Sirainen Date: Fri, 19 Mar 2010 13:19:49 +0000 (+0200) Subject: dbox: Use mail's transaction view instead of mailbox's view whenever possible. X-Git-Tag: 2.0.beta4~20 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=767ff4367960efd5fa868f3b56f850fd4c205c8b;p=thirdparty%2Fdovecot%2Fcore.git dbox: Use mail's transaction view instead of mailbox's view whenever possible. This fixes crash when saving/copying fails. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/dbox-multi/mdbox-mail.c b/src/lib-storage/index/dbox-multi/mdbox-mail.c index 6ed52fd7d8..2598a350d1 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-mail.c +++ b/src/lib-storage/index/dbox-multi/mdbox-mail.c @@ -62,7 +62,7 @@ static void dbox_mail_set_expunged(struct dbox_mail *mail, uint32_t map_uid) struct mdbox_mailbox *mbox = (struct mdbox_mailbox *)_mail->box; (void)mail_index_refresh(_mail->box->index); - if (mail_index_is_expunged(_mail->box->view, _mail->seq)) { + if (mail_index_is_expunged(_mail->transaction->view, _mail->seq)) { mail_set_expunged(_mail); return; } @@ -114,7 +114,7 @@ int mdbox_mail_open(struct dbox_mail *mail, uoff_t *offset_r, if (mail->open_file != NULL) { /* already open */ } else if (_mail->uid != 0) { - if (mdbox_mail_lookup(mbox, _mail->box->view, + if (mdbox_mail_lookup(mbox, _mail->transaction->view, _mail->seq, &map_uid) < 0) return -1; if (dbox_mail_open_init(mail, map_uid) < 0) @@ -160,7 +160,7 @@ static int mdbox_mail_get_save_date(struct mail *mail, time_t *date_r) const void *data; bool expunged; - mail_index_lookup_ext(mail->box->view, mail->seq, + mail_index_lookup_ext(mail->transaction->view, mail->seq, mbox->ext_id, &data, &expunged); dbox_rec = data; if (dbox_rec == NULL || dbox_rec->map_uid == 0) { diff --git a/src/lib-storage/index/dbox-multi/mdbox-save.c b/src/lib-storage/index/dbox-multi/mdbox-save.c index 712eee9d78..73fed84a11 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-save.c +++ b/src/lib-storage/index/dbox-multi/mdbox-save.c @@ -368,7 +368,7 @@ int mdbox_copy(struct mail_save_context *_ctx, struct mail *mail) memset(&rec, 0, sizeof(rec)); rec.save_date = ioloop_time; - if (mdbox_mail_lookup(src_mbox, mail->box->view, mail->seq, + if (mdbox_mail_lookup(src_mbox, mail->transaction->view, mail->seq, &rec.map_uid) < 0) return -1; @@ -382,7 +382,7 @@ int mdbox_copy(struct mail_save_context *_ctx, struct mail *mail) mail_index_update_ext(ctx->ctx.trans, ctx->ctx.seq, ctx->mbox->ext_id, &rec, NULL); - mail_index_lookup_ext(mail->box->view, mail->seq, + mail_index_lookup_ext(mail->transaction->view, mail->seq, src_mbox->guid_ext_id, &data, &expunged); if (data != NULL) { mail_index_update_ext(ctx->ctx.trans, ctx->ctx.seq, diff --git a/src/lib-storage/index/dbox-single/sdbox-mail.c b/src/lib-storage/index/dbox-single/sdbox-mail.c index 01468fe014..77c55bd525 100644 --- a/src/lib-storage/index/dbox-single/sdbox-mail.c +++ b/src/lib-storage/index/dbox-single/sdbox-mail.c @@ -18,7 +18,7 @@ static void sdbox_mail_set_expunged(struct dbox_mail *mail) struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)_mail->box; (void)mail_index_refresh(_mail->box->index); - if (mail_index_is_expunged(_mail->box->view, _mail->seq)) { + if (mail_index_is_expunged(_mail->transaction->view, _mail->seq)) { mail_set_expunged(_mail); return; }