Mercurial > dovecot > core-2.2
changeset 13609:09707b608d8d
imapc: Fixed fetching data for a saved, but uncommitted, mail.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 05 Oct 2011 17:55:29 +0300 |
parents | fab95106bcd6 |
children | a70f6f04f1fe |
files | src/lib-storage/index/imapc/imapc-mail-fetch.c src/lib-storage/index/imapc/imapc-storage.c src/lib-storage/index/imapc/imapc-storage.h |
diffstat | 3 files changed, 22 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-mail-fetch.c Wed Oct 05 17:51:32 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-mail-fetch.c Wed Oct 05 17:55:29 2011 +0300 @@ -68,20 +68,23 @@ if (fields == 0) return 0; - if (_mail->saving) { - mail_storage_set_critical(_mail->box->storage, - "Can't fetch data from uncommitted message"); - return -1; - } + if (!_mail->saving) { + /* if we already know that the mail is expunged, + don't try to FETCH it */ + view = mbox->delayed_sync_view != NULL ? + mbox->delayed_sync_view : mbox->box.view; + if (!mail_index_lookup_seq(view, _mail->uid, &seq) || + mail_index_is_expunged(view, seq)) { + mail_set_expunged(_mail); + return -1; + } + } else if (mbox->client_box == NULL) { + /* opened as save-only. we'll need to fetch the mail, + so actually SELECT/EXAMINE the mailbox */ + i_assert(mbox->box.opened); - /* if we already know that the mail is expunged, - don't try to FETCH it */ - view = mbox->delayed_sync_view != NULL ? - mbox->delayed_sync_view : mbox->box.view; - if (!mail_index_lookup_seq(view, _mail->uid, &seq) || - mail_index_is_expunged(view, seq)) { - mail_set_expunged(_mail); - return -1; + if (imapc_mailbox_select(mbox) < 0) + return -1; } if ((fields & MAIL_FETCH_STREAM_BODY) != 0)
--- a/src/lib-storage/index/imapc/imapc-storage.c Wed Oct 05 17:51:32 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Wed Oct 05 17:55:29 2011 +0300 @@ -383,13 +383,14 @@ imapc_client_stop(ctx->mbox->storage->client); } -static int imapc_mailbox_select(struct imapc_mailbox *mbox) +int imapc_mailbox_select(struct imapc_mailbox *mbox) { struct imapc_open_context ctx; - bool examine; + bool examine = TRUE; - examine = (mbox->box.flags & MAILBOX_FLAG_READONLY) != 0 && - (mbox->box.flags & MAILBOX_FLAG_DROP_RECENT) == 0; + examine = (mbox->box.flags & MAILBOX_FLAG_DROP_RECENT) == 0 && + ((mbox->box.flags & MAILBOX_FLAG_READONLY) != 0 || + (mbox->box.flags & MAILBOX_FLAG_SAVEONLY) != 0); mbox->selecting = TRUE; ctx.mbox = mbox;
--- a/src/lib-storage/index/imapc/imapc-storage.h Wed Oct 05 17:51:32 2011 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.h Wed Oct 05 17:55:29 2011 +0300 @@ -105,6 +105,7 @@ void imapc_storage_run(struct imapc_storage *storage); void imapc_mail_cache_free(struct imapc_mail_cache *cache); +int imapc_mailbox_select(struct imapc_mailbox *mbox); void imapc_copy_error_from_reply(struct imapc_storage *storage, enum mail_error default_error,