Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7295:a39b16b0a530 HEAD
quota_rule=?:.. specifies the default quota limits to use when backend
doesn't have any. If backend has limits, this rule is ignored.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 26 Feb 2008 16:29:46 +0200 |
parents | 9e4c26471b19 |
children | ecf5a34a4758 |
files | src/plugins/quota/quota-maildir.c src/plugins/quota/quota-private.h src/plugins/quota/quota.c |
diffstat | 3 files changed, 18 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/quota/quota-maildir.c Tue Feb 26 16:21:05 2008 +0200 +++ b/src/plugins/quota/quota-maildir.c Tue Feb 26 16:29:46 2008 +0200 @@ -32,7 +32,6 @@ off_t last_size; unsigned int limits_initialized:1; - unsigned int master_message_limits:1; }; struct maildir_list_context { @@ -290,7 +289,7 @@ static void maildirsize_rebuild_later(struct maildir_quota_root *root) { - if (!root->master_message_limits) { + if (!root->root.force_default_rule) { /* FIXME: can't unlink(), because the limits would be lost. */ return; } @@ -403,7 +402,7 @@ if (rule->bytes_limit == (int64_t)message_bytes_limit && rule->count_limit == (int64_t)message_count_limit) { /* limits haven't changed */ - } else if (root->master_message_limits) { + } else if (root->root.force_default_rule) { /* we know the limits and they've changed. the file must be rewritten. */ return 0; @@ -551,22 +550,15 @@ static bool maildirquota_limits_init(struct maildir_quota_root *root) { - if (root->limits_initialized) - return root->maildirsize_path != NULL; - root->limits_initialized = TRUE; + if (!root->limits_initialized) { + root->limits_initialized = TRUE; - /* these limits must be checked before the maildirsize is read the - first time. if master limits aren't used, the default rule limits - will be zero initially, but they'll be updated after the file is - read. */ - if (root->root.default_rule.bytes_limit != 0 || - root->root.default_rule.count_limit != 0) - root->master_message_limits = TRUE; + if (root->maildirsize_path == NULL) { + i_warning("quota maildir: No maildir storages, " + "ignoring quota."); + } + } - if (root->maildirsize_path == NULL) { - i_warning("quota maildir: No maildir storages, " - "ignoring quota."); - } return root->maildirsize_path != NULL; }
--- a/src/plugins/quota/quota-private.h Tue Feb 26 16:21:05 2008 +0200 +++ b/src/plugins/quota/quota-private.h Tue Feb 26 16:29:46 2008 +0200 @@ -78,6 +78,8 @@ /* don't enforce quota when saving */ unsigned int no_enforcing:1; + /* Limits in default_rule override backend's quota limits */ + unsigned int force_default_rule:1; }; struct quota_transaction_context {
--- a/src/plugins/quota/quota.c Tue Feb 26 16:21:05 2008 +0200 +++ b/src/plugins/quota/quota.c Tue Feb 26 16:29:46 2008 +0200 @@ -12,7 +12,8 @@ #include <sys/wait.h> #define DEFAULT_QUOTA_EXCEEDED_MSG "Quota exceeded" -#define RULE_NAME_ALL_MAILBOXES "*" +#define RULE_NAME_DEFAULT_FORCE "*" +#define RULE_NAME_DEFAULT_NONFORCE "?" struct quota_root_iter { struct quota *quota; @@ -341,9 +342,12 @@ rule = quota_root_rule_find(root, mailbox_name); if (rule == NULL) { - if (strcmp(mailbox_name, RULE_NAME_ALL_MAILBOXES) == 0) + if (strcmp(mailbox_name, RULE_NAME_DEFAULT_NONFORCE) == 0) rule = &root->default_rule; - else { + else if (strcmp(mailbox_name, RULE_NAME_DEFAULT_FORCE) == 0) { + rule = &root->default_rule; + root->force_default_rule = TRUE; + } else { rule = array_append_space(&root->rules); rule->mailbox_name = p_strdup(root->pool, mailbox_name); }