}
}
+static bool virtual_backend_box_can_close(struct virtual_backend_box *bbox)
+{
+ if (bbox->box->notify_callback != NULL) {
+ /* FIXME: IMAP IDLE running - we should support closing this
+ also if mailbox_list_index=yes */
+ return FALSE;
+ }
+ if (array_count(&bbox->sync_pending_removes) > 0) {
+ /* FIXME: we could probably close this by making
+ syncing support it? */
+ return FALSE;
+ }
+ return TRUE;
+}
+
static bool
virtual_backend_box_close_any_except(struct virtual_mailbox *mbox,
struct virtual_backend_box *except_bbox)
if (bbox != except_bbox &&
bbox->box->transaction_count == 0 &&
- bbox->box->notify_callback == NULL) {
+ virtual_backend_box_can_close(bbox)) {
i_assert(bbox->sync_mail == NULL);
virtual_backend_box_close(mbox, bbox);
return TRUE;
if (bbox != except_bbox &&
bbox->sync_mail != NULL &&
bbox->box->transaction_count == 1 &&
- bbox->box->notify_callback == NULL) {
+ virtual_backend_box_can_close(bbox)) {
virtual_backend_box_sync_mail_unset(bbox);
i_assert(bbox->box->transaction_count == 0);
virtual_backend_box_close(mbox, bbox);
MAILBOX_SYNC_FLAG_FAST);
if (bbox->search_result == NULL) {
- /* first sync in this process. first try to quickly check
- if the mailbox has changed. if we can do that check from
- mailbox list index, we don't even need to open the
- mailbox. */
- i_assert(array_count(&bbox->sync_pending_removes) == 0);
+ /* a) first sync in this process.
+ b) we had auto-closed this backend mailbox.
+ first try to quickly check if the mailbox has changed.
+ if we can do that check from mailbox list index, we don't
+ even need to open the mailbox. */
+ i_assert(array_count(&bbox->sync_pending_removes) == 0);
if (bbox_index_opened || bbox->open_failed) {
/* a) index already opened, refresh it
b) delayed error handling for mailbox_open()