]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Added MAILBOX_FLAG_DELETE_UNSAFE
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 27 May 2016 19:15:07 +0000 (22:15 +0300)
committerGitLab <gitlab@git.dovecot.net>
Mon, 30 May 2016 12:26:00 +0000 (15:26 +0300)
src/lib-storage/mail-storage.h
src/plugins/lazy-expunge/lazy-expunge-plugin.c
src/plugins/quota/quota-storage.c

index 4c99849e50b03a8543ea4e2d995aee59d063b4f4..64804b4f334e68d6c9979cf93faf5f64d4a3bc68 100644 (file)
@@ -49,7 +49,13 @@ enum mailbox_flags {
        /* Force opening mailbox and ignoring any ACLs */
        MAILBOX_FLAG_IGNORE_ACLS        = 0x100,
        /* Open mailbox even if it's already marked as deleted */
-       MAILBOX_FLAG_OPEN_DELETED       = 0x200
+       MAILBOX_FLAG_OPEN_DELETED       = 0x200,
+       /* Mailbox is opened for deletion, which should be performed as
+          efficiently as possible, even allowing the mailbox state to become
+          inconsistent. For example this disables lazy_expunge plugin and
+          quota updates (possibly resulting in broken quota). and This is
+          useful for example when deleting entire user accounts. */
+       MAILBOX_FLAG_DELETE_UNSAFE      = 0x400
 };
 
 enum mailbox_feature {
index 47e16253655ce1b101a1f990d63ddbe5c2443147..c943fffa8ce645c3285b524bb16500d4f8a5579e 100644 (file)
@@ -448,7 +448,7 @@ static void lazy_expunge_mailbox_allocated(struct mailbox *box)
        union mailbox_module_context *mbox;
        struct mailbox_vfuncs *v = box->vlast;
 
-       if (llist == NULL)
+       if (llist == NULL || (box->flags & MAILBOX_FLAG_DELETE_UNSAFE) != 0)
                return;
 
        mbox = p_new(box->pool, union mailbox_module_context, 1);
index bd65663b5372abfdf30e901e6565194d113b1476..4d75a319437c3e504042b02ba534d452df7d5d43 100644 (file)
@@ -328,7 +328,8 @@ static void quota_mailbox_sync_notify(struct mailbox *box, uint32_t uid,
        if (qbox->module_ctx.super.sync_notify != NULL)
                qbox->module_ctx.super.sync_notify(box, uid, sync_type);
 
-       if (sync_type != MAILBOX_SYNC_TYPE_EXPUNGE || qbox->recalculate) {
+       if (sync_type != MAILBOX_SYNC_TYPE_EXPUNGE || qbox->recalculate ||
+           (box->flags & MAILBOX_FLAG_DELETE_UNSAFE) != 0) {
                if (uid == 0) {
                        /* free the transaction before view syncing begins,
                           otherwise it'll crash. */