dovecot-2.0: Maildir++ quota: % limits weren't updated when limi...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Dec 9 00:50:48 EET 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/4002e686d38d
changeset: 10433:4002e686d38d
user: Timo Sirainen <tss at iki.fi>
date: Tue Dec 08 17:50:37 2009 -0500
description:
Maildir++ quota: % limits weren't updated when limits were read from maildirsize.
diffstat:
3 files changed, 21 insertions(+), 12 deletions(-)
src/plugins/quota/quota-maildir.c | 4 +++-
src/plugins/quota/quota-private.h | 4 +++-
src/plugins/quota/quota.c | 25 +++++++++++++++----------
diffs (94 lines):
diff -r 2f294ba2168a -r 4002e686d38d src/plugins/quota/quota-maildir.c
--- a/src/plugins/quota/quota-maildir.c Tue Dec 08 16:32:49 2009 -0500
+++ b/src/plugins/quota/quota-maildir.c Tue Dec 08 17:50:37 2009 -0500
@@ -467,7 +467,9 @@ static int maildirsize_parse(struct mail
/* we're using limits from the file. */
root->root.bytes_limit = message_bytes_limit;
root->root.count_limit = message_count_limit;
- quota_root_recalculate_relative_rules(root->root.set);
+ quota_root_recalculate_relative_rules(root->root.set,
+ message_bytes_limit,
+ message_count_limit);
}
if (*lines == NULL) {
diff -r 2f294ba2168a -r 4002e686d38d src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h Tue Dec 08 16:32:49 2009 -0500
+++ b/src/plugins/quota/quota-private.h Tue Dec 08 17:50:37 2009 -0500
@@ -146,7 +146,9 @@ struct quota_rule *
struct quota_rule *
quota_root_rule_find(struct quota_root_settings *root_set, const char *name);
-void quota_root_recalculate_relative_rules(struct quota_root_settings *root_set);
+void quota_root_recalculate_relative_rules(struct quota_root_settings *root_set,
+ int64_t bytes_limit,
+ int64_t count_limit);
int quota_count(struct quota_root *root, uint64_t *bytes_r, uint64_t *count_r);
#endif
diff -r 2f294ba2168a -r 4002e686d38d src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c Tue Dec 08 16:32:49 2009 -0500
+++ b/src/plugins/quota/quota.c Tue Dec 08 17:50:37 2009 -0500
@@ -323,31 +323,32 @@ quota_rule_parse_percentage(struct quota
static void
quota_rule_recalculate_relative_rules(struct quota_rule *rule,
- const struct quota_rule *default_rule)
+ int64_t bytes_limit, int64_t count_limit)
{
if (rule->bytes_percent > 0) {
- rule->bytes_limit = default_rule->bytes_limit *
- rule->bytes_percent / 100;
+ rule->bytes_limit = bytes_limit * rule->bytes_percent / 100;
}
if (rule->count_percent > 0) {
- rule->count_limit = default_rule->count_limit *
+ rule->count_limit = count_limit *
rule->count_percent / 100;
}
}
-void quota_root_recalculate_relative_rules(struct quota_root_settings *root_set)
+void quota_root_recalculate_relative_rules(struct quota_root_settings *root_set,
+ int64_t bytes_limit,
+ int64_t count_limit)
{
struct quota_rule *rule;
struct quota_warning_rule *warning_rule;
array_foreach_modifiable(&root_set->rules, rule) {
- quota_rule_recalculate_relative_rules(rule,
- &root_set->default_rule);
+ quota_rule_recalculate_relative_rules(rule, bytes_limit,
+ count_limit);
}
array_foreach_modifiable(&root_set->warning_rules, warning_rule) {
quota_rule_recalculate_relative_rules(&warning_rule->rule,
- &root_set->default_rule);
+ bytes_limit, count_limit);
}
}
@@ -477,7 +478,9 @@ int quota_root_add_rule(struct quota_roo
ret = -1;
}
- quota_root_recalculate_relative_rules(root_set);
+ quota_root_recalculate_relative_rules(root_set,
+ root_set->default_rule.bytes_limit,
+ root_set->default_rule.count_limit);
if (root_set->set->debug) {
i_debug("Quota rule: root=%s mailbox=%s "
"bytes=%lld%s messages=%lld%s", root_set->name,
@@ -623,7 +626,9 @@ int quota_root_add_warning_rule(struct q
warning->command = i_strdup(p+1);
warning->rule = rule;
- quota_root_recalculate_relative_rules(root_set);
+ quota_root_recalculate_relative_rules(root_set,
+ root_set->default_rule.bytes_limit,
+ root_set->default_rule.count_limit);
if (root_set->set->debug) {
i_debug("Quota warning: bytes=%llu%s "
"messages=%llu%s command=%s",
More information about the dovecot-cvs
mailing list