Mercurial > dovecot > core-2.2
changeset 9565:eda6f7c67058 HEAD
quota: Rules use virtual mailbox names now (as they always should have).
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 07 Jul 2009 14:44:46 -0400 |
parents | 279af9682cd6 |
children | 2c90d6cf8b09 |
files | src/plugins/quota/quota-storage.c src/plugins/quota/quota.c |
diffstat | 2 files changed, 29 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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 @@ 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); }
--- 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 @@ 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 @@ 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 @@ continue; if (!quota_root_get_rule_limits(roots[i], - mailbox_get_name(ctx->box), + mailbox_get_vname(ctx->box), &bytes_limit, &count_limit)) continue;