unsigned int creating:1;
/* Mailbox is being deleted */
unsigned int deleting:1;
+ /* Mailbox is being undeleted */
+ unsigned int mailbox_undeleting:1;
/* Don't use MAIL_INDEX_SYNC_FLAG_DELETING_INDEX for sync flag */
unsigned int delete_sync_check:1;
/* Delete mailbox only if it's empty */
{
time_t mtime;
+ i_assert(!box->mailbox_undeleting);
+
if ((box->flags & MAILBOX_FLAG_READONLY) != 0) {
/* most importantly we don't do this because we want to avoid
a loop: mdbox storage rebuild -> mailbox_open() ->
if (mtime + MAILBOX_DELETE_RETRY_SECS > time(NULL))
return FALSE;
- if (mailbox_mark_index_deleted(box, FALSE) < 0)
+ box->mailbox_undeleting = TRUE;
+ int ret = mailbox_mark_index_deleted(box, FALSE);
+ box->mailbox_undeleting = FALSE;
+ if (ret < 0)
return FALSE;
box->mailbox_deleted = FALSE;
return TRUE;
}
if (mailbox_open_full(box, NULL) < 0) {
- if (!box->mailbox_deleted)
+ if (!box->mailbox_deleted || box->mailbox_undeleting)
return -1;
/* mailbox has been marked as deleted. if this deletion