]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Rules use virtual mailbox names now (as they always should have).
authorTimo Sirainen <tss@iki.fi>
Tue, 7 Jul 2009 18:44:46 +0000 (14:44 -0400)
committerTimo Sirainen <tss@iki.fi>
Tue, 7 Jul 2009 18:44:46 +0000 (14:44 -0400)
--HG--
branch : HEAD

src/plugins/quota/quota-storage.c
src/plugins/quota/quota.c

index f3abdf3f919dedd74d13e6b2bb85d396810afb18..3bfd2fd2a2e78f71f7b06ccbddf2b8dc55870d02 100644 (file)
@@ -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(&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);
 }
index fe96b6375ed0d698c3c2f7b3136531b8ec532b06..7dc5fe2b6fcd9cd2b4db122b6a88fe1b235d8631 100644 (file)
@@ -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;