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)
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;
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,