From: Timo Sirainen Date: Wed, 12 Jul 2017 23:56:33 +0000 (+0300) Subject: quota: When setting auto_updating to transaction, skip invisible quota roots X-Git-Tag: 2.3.0.rc1~1264 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3e170cc66eda9e1775825a5713c2d2b6a4891a04;p=thirdparty%2Fdovecot%2Fcore.git quota: When setting auto_updating to transaction, skip invisible quota roots Skip the quota root also if the mailbox matches "ignore" quota_rule. This is only an optimization fix so that unnecessary work isn't done for quota roots that aren't actually used. --- diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index 0d26c0cd10..0a0de28402 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -830,6 +830,8 @@ struct quota_transaction_context *quota_transaction_begin(struct mailbox *box) { struct quota_transaction_context *ctx; struct quota_root *const *rootp; + const struct quota_rule *rule; + const char *mailbox_name; ctx = i_new(struct quota_transaction_context, 1); ctx->quota = box->list->ns->owner != NULL ? @@ -842,8 +844,23 @@ struct quota_transaction_context *quota_transaction_begin(struct mailbox *box) ctx->bytes_ceil2 = (uint64_t)-1; ctx->count_ceil = (uint64_t)-1; + mailbox_name = mailbox_get_vname(box); + (void)mail_namespace_find_unalias(box->storage->user->namespaces, + &mailbox_name); + ctx->auto_updating = TRUE; array_foreach(&ctx->quota->roots, rootp) { + if (!quota_root_is_visible(*rootp, ctx->box, FALSE)) + continue; + + rule = quota_root_rule_find((*rootp)->set, mailbox_name); + if (rule != NULL && rule->ignore) { + /* This mailbox isn't included in quota. This means + it's also not included in quota_warnings, so make + sure it's fully ignored. */ + continue; + } + if (!(*rootp)->auto_updating) ctx->auto_updating = FALSE; }