changeset 22333:6af385105911

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.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 13 Jul 2017 02:56:33 +0300
parents 2c3691145654
children 985aa5b0546b
files src/plugins/quota/quota.c
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/quota/quota.c	Tue Jul 11 10:45:16 2017 +0300
+++ b/src/plugins/quota/quota.c	Thu Jul 13 02:56:33 2017 +0300
@@ -827,6 +827,8 @@
 {
 	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 @@
 	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;
 	}