diff --git a/src/plugins/lazy-expunge/lazy-expunge-plugin.c b/src/plugins/lazy-expunge/lazy-expunge-plugin.c index cce392dac5..e69e372bcb 100644 --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c @@ -125,13 +125,19 @@ mailbox_open_or_create(struct mailbox_list *list, struct mailbox *src_box, } /* try creating and re-opening it. */ - if (mailbox_create(box, NULL, FALSE) < 0 || - mailbox_open(box) < 0) { + if (mailbox_create(box, NULL, FALSE) < 0 && + mailbox_get_last_mail_error(box) != MAIL_ERROR_EXISTS) { *error_r = t_strdup_printf("Failed to create mailbox %s: %s", name, mailbox_get_last_error(box, NULL)); mailbox_free(&box); return NULL; } + if (mailbox_open(box) < 0) { + *error_r = t_strdup_printf("Failed to open created mailbox %s: %s", name, + mailbox_get_last_error(box, NULL)); + mailbox_free(&box); + return NULL; + } return box; }