dovecot-2.0: quota: Rules use virtual mailbox names now (as they...

dovecot at dovecot.org dovecot at dovecot.org
Tue Jul 7 21:46:57 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/eda6f7c67058
changeset: 9565:eda6f7c67058
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Jul 07 14:44:46 2009 -0400
description:
quota: Rules use virtual mailbox names now (as they always should have).

diffstat:

2 files changed, 30 insertions(+), 15 deletions(-)
src/plugins/quota/quota-storage.c |   39 +++++++++++++++++++++++++------------
src/plugins/quota/quota.c         |    6 ++---

diffs (83 lines):

diff -r 279af9682cd6 -r eda6f7c67058 src/plugins/quota/quota-storage.c
--- a/src/plugins/quota/quota-storage.c	Tue Jul 07 14:41:35 2009 -0400
+++ b/src/plugins/quota/quota-storage.c	Tue Jul 07 14:44:46 2009 -0400
@@ -581,6 +581,30 @@ void quota_mailbox_list_created(struct m
 		quota_next_hook_mailbox_list_created(list);
 }
 
+static void quota_root_set_namespace(struct quota_root *root,
+				     struct mail_namespace *namespaces)
+{
+	const struct quota_rule *rules;
+	unsigned int i, count;
+	const char *name;
+
+	if (root->ns_prefix != NULL && root->ns == NULL) {
+		root->ns = mail_namespace_find_prefix(namespaces,
+						      root->ns_prefix);
+		if (root->ns == NULL) {
+			i_error("quota: Unknown namespace: %s",
+				root->ns_prefix);
+		}
+	}
+
+	rules = array_get(&root->set->rules, &count);
+	for (i = 0; i < count; i++) {
+		name = rules[i].mailbox_name;
+		if (mail_namespace_find(namespaces, &name) == NULL)
+			i_error("quota: Unknown namespace: %s", name);
+	}
+}
+
 void quota_mail_namespaces_created(struct mail_namespace *namespaces)
 {
 	struct quota *quota;
@@ -589,15 +613,6 @@ void quota_mail_namespaces_created(struc
 
 	quota = quota_get_mail_user_quota(namespaces->user);
 	roots = array_get(&quota->roots, &count);
-	for (i = 0; i < count; i++) {
-		if (roots[i]->ns_prefix == NULL || roots[i]->ns != NULL)
-			continue;
-
-		roots[i]->ns = mail_namespace_find_prefix(namespaces,
-							  roots[i]->ns_prefix);
-		if (roots[i]->ns == NULL) {
-			i_error("maildir quota: Unknown namespace: %s",
-				roots[i]->ns_prefix);
-		}
-	}
-}
+	for (i = 0; i < count; i++)
+		quota_root_set_namespace(roots[i], namespaces);
+}
diff -r 279af9682cd6 -r eda6f7c67058 src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Tue Jul 07 14:41:35 2009 -0400
+++ b/src/plugins/quota/quota.c	Tue Jul 07 14:44:46 2009 -0400
@@ -819,7 +819,7 @@ static int quota_transaction_set_limits(
 	int ret;
 
 	ctx->limits_set = TRUE;
-	mailbox_name = mailbox_get_name(ctx->box);
+	mailbox_name = mailbox_get_vname(ctx->box);
 
 	/* find the lowest quota limits from all roots and use them */
 	roots = array_get(&ctx->quota->roots, &count);
@@ -928,7 +928,7 @@ int quota_transaction_commit(struct quot
 		ret = -1;
 	else if (ctx->bytes_used != 0 || ctx->count_used != 0 ||
 		 ctx->recalculate) {
-		mailbox_name = mailbox_get_name(ctx->box);
+		mailbox_name = mailbox_get_vname(ctx->box);
 		roots = array_get(&ctx->quota->roots, &count);
 		for (i = 0; i < count; i++) {
 			if (!quota_root_is_visible(roots[i], ctx->box, FALSE))
@@ -1012,7 +1012,7 @@ static int quota_default_test_alloc(stru
 			continue;
 
 		if (!quota_root_get_rule_limits(roots[i],
-						mailbox_get_name(ctx->box),
+						mailbox_get_vname(ctx->box),
 						&bytes_limit, &count_limit))
 			continue;
 


More information about the dovecot-cvs mailing list