Skip to content

Commit

Permalink
lib-storage: Added MAILBOX_FLAG_DELETE_UNSAFE
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen authored and GitLab committed May 30, 2016
1 parent 9385b31 commit f8a63c1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/lib-storage/mail-storage.h
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/lazy-expunge/lazy-expunge-plugin.c
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/quota/quota-storage.c
Expand Up @@ -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. */
Expand Down

0 comments on commit f8a63c1

Please sign in to comment.