i_assert(headers == NULL ||
IMAPC_BOX_HAS_FEATURE(mbox, IMAPC_FEATURE_FETCH_HEADERS));
+ if (!mbox->selected) {
+ mail_storage_set_error(_mail->box->storage,
+ MAIL_ERROR_NOTPOSSIBLE, "Can't fetch mails before selecting mailbox");
+ return -1;
+ }
+
if (!mail_stream_access_start(_mail))
return -1;
}
}
+static bool imapc_mailbox_need_initial_fetch(struct imapc_mailbox *mbox)
+{
+ if (mbox->box.deleting) {
+ /* If the mailbox is about to be deleted there is no need to
+ expect initial fetch to be done */
+ return FALSE;
+ }
+ if ((mbox->box.flags & MAILBOX_FLAG_SAVEONLY) != 0) {
+ /* The mailbox is opened only for saving there is no need to
+ expect initial fetchting do be done. */
+ return FALSE;
+ }
+ return TRUE;
+}
+
struct mailbox_sync_context *
imapc_mailbox_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
{
if (imapc_storage_client_handle_auth_failure(mbox->storage->client))
ret = -1;
else if (!mbox->state_fetched_success && !mbox->state_fetching_uid1 &&
- !mbox->box.deleting) {
+ imapc_mailbox_need_initial_fetch(mbox)) {
/* initial FETCH failed already */
ret = -1;
}