dovecot-2.1: lib-storage: Added mailbox_delete_empty().
dovecot at dovecot.org
dovecot at dovecot.org
Thu Apr 19 18:16:07 EEST 2012
details: http://hg.dovecot.org/dovecot-2.1/rev/2d8bafd11569
changeset: 14427:2d8bafd11569
user: Timo Sirainen <tss at iki.fi>
date: Thu Apr 19 18:15:37 2012 +0300
description:
lib-storage: Added mailbox_delete_empty().
diffstat:
src/lib-storage/index/index-storage.c | 6 ++++--
src/lib-storage/mail-storage-private.h | 2 ++
src/lib-storage/mail-storage.c | 12 ++++++++++++
src/lib-storage/mail-storage.h | 3 +++
4 files changed, 21 insertions(+), 2 deletions(-)
diffs (63 lines):
diff -r ff07827db69a -r 2d8bafd11569 src/lib-storage/index/index-storage.c
--- a/src/lib-storage/index/index-storage.c Thu Apr 19 14:39:26 2012 +0300
+++ b/src/lib-storage/index/index-storage.c Thu Apr 19 18:15:37 2012 +0300
@@ -535,8 +535,10 @@
no) finish deleting the mailbox
*/
- if (mailbox_expunge_all_mails(box) < 0)
- return -1;
+ if (!box->deleting_must_be_empty) {
+ if (mailbox_expunge_all_mails(box) < 0)
+ return -1;
+ }
if (mailbox_mark_index_deleted(box, TRUE) < 0)
return -1;
diff -r ff07827db69a -r 2d8bafd11569 src/lib-storage/mail-storage-private.h
--- a/src/lib-storage/mail-storage-private.h Thu Apr 19 14:39:26 2012 +0300
+++ b/src/lib-storage/mail-storage-private.h Thu Apr 19 18:15:37 2012 +0300
@@ -265,6 +265,8 @@
unsigned int creating:1;
/* Mailbox is being deleted */
unsigned int deleting:1;
+ /* Delete mailbox only if it's empty */
+ unsigned int deleting_must_be_empty:1;
/* Mailbox was already marked as deleted within this allocation. */
unsigned int marked_deleted:1;
/* TRUE if this is an INBOX for this user */
diff -r ff07827db69a -r 2d8bafd11569 src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c Thu Apr 19 14:39:26 2012 +0300
+++ b/src/lib-storage/mail-storage.c Thu Apr 19 18:15:37 2012 +0300
@@ -1106,6 +1106,18 @@
return ret;
}
+int mailbox_delete_empty(struct mailbox *box)
+{
+ int ret;
+
+ /* FIXME: should be a parameter to delete(), but since it changes API
+ don't do it for now */
+ box->deleting_must_be_empty = TRUE;
+ ret = mailbox_delete(box);
+ box->deleting_must_be_empty = FALSE;
+ return ret;
+}
+
static bool
mail_storages_rename_compatible(struct mail_storage *storage1,
struct mail_storage *storage2,
diff -r ff07827db69a -r 2d8bafd11569 src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h Thu Apr 19 14:39:26 2012 +0300
+++ b/src/lib-storage/mail-storage.h Thu Apr 19 18:15:37 2012 +0300
@@ -417,6 +417,9 @@
int mailbox_update(struct mailbox *box, const struct mailbox_update *update);
/* Delete mailbox (and its parent directory, if it has no siblings) */
int mailbox_delete(struct mailbox *box);
+/* Delete mailbox, but only if it's empty. If it's not, fails with
+ MAIL_ERROR_EXISTS. */
+int mailbox_delete_empty(struct mailbox *box);
/* Rename mailbox. Renaming across different mailbox lists is possible only
between private namespaces and storages of the same type. If the rename
fails, the error is set to src's storage. */
More information about the dovecot-cvs
mailing list