From eafecb7ad0fbbde0da8be7e8ae735459b7bb688b Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 7 Jul 2009 14:44:46 -0400 Subject: [PATCH] quota: Rules use virtual mailbox names now (as they always should have). --HG-- branch : HEAD --- src/plugins/quota/quota-storage.c | 37 ++++++++++++++++++++++--------- src/plugins/quota/quota.c | 6 ++--- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/plugins/quota/quota-storage.c b/src/plugins/quota/quota-storage.c index f3abdf3f91..3bfd2fd2a2 100644 --- a/src/plugins/quota/quota-storage.c +++ b/src/plugins/quota/quota-storage.c @@ -581,6 +581,30 @@ void quota_mailbox_list_created(struct mailbox_list *list) 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(struct mail_namespace *namespaces) quota = quota_get_mail_user_quota(namespaces->user); roots = array_get("a->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 --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index fe96b6375e..7dc5fe2b6f 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -819,7 +819,7 @@ static int quota_transaction_set_limits(struct quota_transaction_context *ctx) 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 quota_transaction_context **_ctx) 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(struct quota_transaction_context *ctx, continue; if (!quota_root_get_rule_limits(roots[i], - mailbox_get_name(ctx->box), + mailbox_get_vname(ctx->box), &bytes_limit, &count_limit)) continue; -- 2.47.3