]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Consistently assume that mailbox names in quota rules are virtual names.
authorTimo Sirainen <tss@iki.fi>
Thu, 17 Jun 2010 19:57:22 +0000 (20:57 +0100)
committerTimo Sirainen <tss@iki.fi>
Thu, 17 Jun 2010 19:57:22 +0000 (20:57 +0100)
The previous code mixed virtual/real name lookups.

--HG--
branch : HEAD

src/plugins/quota/quota-count.c
src/plugins/quota/quota-maildir.c

index 09214069a6faf2a718c29ff009bee28401a60476..d8ba68a790548c2c84b3064b6a38e4968088378f 100644 (file)
@@ -9,7 +9,7 @@
 
 static int
 quota_count_mailbox(struct quota_root *root, struct mail_namespace *ns,
-                   const char *name, uint64_t *bytes_r, uint64_t *count_r)
+                   const char *vname, uint64_t *bytes_r, uint64_t *count_r)
 {
        struct quota_rule *rule;
        struct mailbox *box;
@@ -17,17 +17,20 @@ quota_count_mailbox(struct quota_root *root, struct mail_namespace *ns,
        struct mail_search_context *ctx;
        struct mail *mail;
        struct mail_search_args *search_args;
+       const char *storage_name;
        enum mail_error error;
        uoff_t size;
        int ret = 0;
 
-       rule = quota_root_rule_find(root->set, name);
+       storage_name = mail_namespace_get_storage_name(ns, vname);
+
+       rule = quota_root_rule_find(root->set, vname);
        if (rule != NULL && rule->ignore) {
                /* mailbox not included in quota */
                return 0;
        }
 
-       box = mailbox_alloc(ns->list, name,
+       box = mailbox_alloc(ns->list, storage_name,
                            MAILBOX_FLAG_READONLY | MAILBOX_FLAG_KEEP_RECENT);
        if (mailbox_open(box) < 0) {
                mail_storage_get_last_error(mailbox_get_storage(box), &error);
@@ -78,6 +81,7 @@ quota_count_namespace(struct quota_root *root, struct mail_namespace *ns,
        int ret = 0;
 
        ctx = mailbox_list_iter_init(ns->list, "*",
+                                    MAILBOX_LIST_ITER_VIRTUAL_NAMES |
                                     MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
        while ((info = mailbox_list_iter_next(ctx)) != NULL) {
                if ((info->flags & (MAILBOX_NONEXISTENT |
index dfcdc2f04a8a91122fa7289054ffe4750534e0b0..a2b60fc548e5ea96aa6738adb6747d1c22fd1252 100644 (file)
@@ -130,6 +130,7 @@ maildir_list_init(struct maildir_quota_root *root, struct mailbox_list *list)
        ctx->path = str_new(default_pool, 512);
        ctx->list = list;
        ctx->iter = mailbox_list_iter_init(list, "*",
+                                          MAILBOX_LIST_ITER_VIRTUAL_NAMES |
                                           MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
        return ctx;
 }
@@ -155,9 +156,11 @@ maildir_list_next(struct maildir_list_context *ctx, time_t *mtime_r)
                }
 
                T_BEGIN {
-                       const char *path;
+                       const char *path, *storage_name;
 
-                       path = mailbox_list_get_path(ctx->list, ctx->info->name,
+                       storage_name = mail_namespace_get_storage_name(
+                               ctx->info->ns, ctx->info->name);
+                       path = mailbox_list_get_path(ctx->list, storage_name,
                                        MAILBOX_LIST_PATH_TYPE_MAILBOX);
                        str_truncate(ctx->path, 0);
                        str_append(ctx->path, path);