Trying to delete a nonexistent autocreated mailbox first created it and then
immediately deleted it.
if (!box->opened) {
/* \noselect mailbox, try deleting only the directory */
- return index_storage_mailbox_delete_dir(box, FALSE);
+ if (index_storage_mailbox_delete_dir(box, FALSE) == 0)
+ return 0;
+ if (mailbox_is_autocreated(box)) {
+ /* Return success when trying to delete autocreated
+ mailbox. The client sees it as existing, so we
+ shouldn't be returning an error. */
+ return 0;
+ }
+ return -1;
}
if ((box->list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) == 0) {
} T_END;
if (ret < 0 && box->storage->error == MAIL_ERROR_NOTFOUND &&
+ !box->deleting &&
box->input == NULL && mailbox_is_autocreated(box)) T_BEGIN {
ret = mailbox_autocreate_and_reopen(box);
} T_END;
if (mailbox_get_last_mail_error(box) != MAIL_ERROR_NOTFOUND &&
!box->mailbox_deleted)
return -1;
- /* \noselect mailbox */
+ /* might be a \noselect mailbox, so continue deletion */
}
ret = box->v.delete_box(box);