Mercurial > dovecot > core-2.2
changeset 16440:7af6795f40ed
imapc: Fixed mailbox deletion.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 01 Jun 2013 03:20:15 +0300 |
parents | cd314aa81805 |
children | 92b4183ede17 |
files | src/lib-storage/index/imapc/imapc-storage.c src/lib-storage/index/index-storage.c src/lib-storage/mail-storage-private.h |
diffstat | 3 files changed, 19 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/imapc/imapc-storage.c Sat Jun 01 03:06:54 2013 +0300 +++ b/src/lib-storage/index/imapc/imapc-storage.c Sat Jun 01 03:20:15 2013 +0300 @@ -666,6 +666,12 @@ status_r->permanent_flags = mbox->permanent_flags; } +static int imapc_mailbox_delete(struct mailbox *box) +{ + box->delete_skip_empty_check = TRUE; + return index_storage_mailbox_delete(box); +} + static int imapc_mailbox_get_status(struct mailbox *box, enum mailbox_status_items items, struct mailbox_status *status_r) @@ -906,7 +912,7 @@ index_storage_mailbox_free, imapc_mailbox_create, imapc_mailbox_update, - index_storage_mailbox_delete, + imapc_mailbox_delete, index_storage_mailbox_rename, imapc_mailbox_get_status, imapc_mailbox_get_metadata,
--- a/src/lib-storage/index/index-storage.c Sat Jun 01 03:06:54 2013 +0300 +++ b/src/lib-storage/index/index-storage.c Sat Jun 01 03:20:15 2013 +0300 @@ -691,13 +691,15 @@ if (mailbox_mark_index_deleted(box, TRUE) < 0) return -1; - if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) - return -1; - mailbox_get_open_status(box, STATUS_MESSAGES, &status); - if (status.messages != 0) { - mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, - "New mails were added to mailbox during deletion"); - return -1; + if (!box->delete_skip_empty_check || box->deleting_must_be_empty) { + if (mailbox_sync(box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) + return -1; + mailbox_get_open_status(box, STATUS_MESSAGES, &status); + if (status.messages != 0) { + mail_storage_set_error(box->storage, MAIL_ERROR_EXISTS, + "New mails were added to mailbox during deletion"); + return -1; + } } ret_guid = mailbox_get_metadata(box, MAILBOX_METADATA_GUID, &metadata);
--- a/src/lib-storage/mail-storage-private.h Sat Jun 01 03:06:54 2013 +0300 +++ b/src/lib-storage/mail-storage-private.h Sat Jun 01 03:20:15 2013 +0300 @@ -320,6 +320,9 @@ unsigned int deleting:1; /* Delete mailbox only if it's empty */ unsigned int deleting_must_be_empty:1; + /* The backend wants to skip checking if there are 0 messages before + calling mailbox_list.delete_mailbox() */ + unsigned int delete_skip_empty_check:1; /* Mailbox was already marked as deleted within this allocation. */ unsigned int marked_deleted:1; /* TRUE if this is an INBOX for this user */