For example with sdbox it may have opened the indexes, but not set mailbox's
GUID. A following MAILBOX_METADATA_GUID would then assert-crash because GUID
is empty.
box->creating = FALSE;
if (ret == 0)
box->list->guid_cache_updated = TRUE;
+ else if (box->opened) {
+ /* Creation failed after (partially) opening the mailbox.
+ It may not be in a valid state, so close it. */
+ mail_storage_last_error_push(box->storage);
+ mailbox_close(box);
+ mail_storage_last_error_pop(box->storage);
+ }
return ret;
}