]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: When setting auto_updating to transaction, skip invisible quota roots
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 12 Jul 2017 23:56:33 +0000 (02:56 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 13 Jul 2017 12:20:20 +0000 (15:20 +0300)
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.

src/plugins/quota/quota.c

index 5aa2ea3c01f8b95b17a9071dd3207fa8698c777a..e006e77c31fb0a64e8b5871a264a6caf3da382fa 100644 (file)
@@ -827,6 +827,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 ?
@@ -839,8 +841,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;
        }