Mercurial > dovecot > core-2.2
changeset 11487:3a0601cb9e67 HEAD
Mailbox deletion: Delay marking its index deleted until ACL has had a chance to abort the deletion.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 07 Jun 2010 14:05:42 +0100 |
parents | 6f5d3e035652 |
children | 4b20e692c606 |
files | src/lib-storage/index/index-storage.c src/lib-storage/mail-storage-private.h src/lib-storage/mail-storage.c src/plugins/lazy-expunge/lazy-expunge-plugin.c |
diffstat | 4 files changed, 14 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/index-storage.c Sat Jun 05 13:38:17 2010 +0100 +++ b/src/lib-storage/index/index-storage.c Mon Jun 07 14:05:42 2010 +0100 @@ -462,6 +462,9 @@ return index_storage_mailbox_delete_dir(box, FALSE); } + if (mailbox_mark_index_deleted(box, TRUE) < 0) + return -1; + if (mailbox_get_guid(box, mailbox_guid) < 0) return -1;
--- a/src/lib-storage/mail-storage-private.h Sat Jun 05 13:38:17 2010 +0100 +++ b/src/lib-storage/mail-storage-private.h Mon Jun 07 14:05:42 2010 +0100 @@ -463,6 +463,7 @@ int mail_set_aborted(struct mail *mail); void mail_set_expunged(struct mail *mail); void mailbox_set_deleted(struct mailbox *box); +int mailbox_mark_index_deleted(struct mailbox *box, bool del); void mailbox_refresh_permissions(struct mailbox *box); /* Returns -1 if error, 0 if failed with EEXIST, 1 if ok */
--- a/src/lib-storage/mail-storage.c Sat Jun 05 13:38:17 2010 +0100 +++ b/src/lib-storage/mail-storage.c Mon Jun 07 14:05:42 2010 +0100 @@ -664,7 +664,7 @@ return box->v.update(box, update); } -static int mailbox_mark_index_deleted(struct mailbox *box, bool del) +int mailbox_mark_index_deleted(struct mailbox *box, bool del) { enum mail_index_transaction_flags trans_flags = 0; struct mail_index_transaction *trans; @@ -737,10 +737,6 @@ } } - if (box->opened) { - if (mailbox_mark_index_deleted(box, TRUE) < 0) - return -1; - } ret = box->v.delete(box); box->deleting = FALSE;
--- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c Sat Jun 05 13:38:17 2010 +0100 +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c Mon Jun 07 14:05:42 2010 +0100 @@ -373,8 +373,11 @@ char timestamp[256]; int ret; - if (llist->internal_namespace) + if (llist->internal_namespace || !box->opened) { + /* a) deleting mailbox from lazy_expunge namespaces + b) deleting a \noselect mailbox */ return lbox->super.delete(box); + } expunge_ns = get_lazy_ns(list->ns->user, LAZY_NAMESPACE_EXPUNGE); dest_ns = get_lazy_ns(list->ns->user, LAZY_NAMESPACE_DELETE); @@ -393,7 +396,11 @@ destname = t_strconcat(box->name, "-", timestamp, NULL); } - /* first move the actual mailbox */ + /* avoid potential race conditions by marking it deleted */ + if (mailbox_mark_index_deleted(box, TRUE) < 0) + return -1; + + /* rename it into the lazy_expunge namespace */ ret = mailbox_move(box, dest_ns->list, destname, &expunge_box); if (ret < 0) return -1;