dovecot-1.2: Maildir++ quota: % limits weren't updated when limi...

dovecot at dovecot.org dovecot at dovecot.org
Wed Dec 9 00:52:32 EET 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/a9b469e1c8de
changeset: 9498:a9b469e1c8de
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Dec 08 17:52:10 2009 -0500
description:
Maildir++ quota: % limits weren't updated when limits were read from maildirsize.

diffstat:

3 files changed, 26 insertions(+), 20 deletions(-)
src/plugins/quota/quota-maildir.c |    4 ++-
src/plugins/quota/quota-private.h |    4 ++-
src/plugins/quota/quota.c         |   38 +++++++++++++++++++------------------

diffs (102 lines):

diff -r b348632b11e2 -r a9b469e1c8de src/plugins/quota/quota-maildir.c
--- a/src/plugins/quota/quota-maildir.c	Tue Dec 08 13:52:14 2009 -0500
+++ b/src/plugins/quota/quota-maildir.c	Tue Dec 08 17:52:10 2009 -0500
@@ -469,7 +469,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 b348632b11e2 -r a9b469e1c8de src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h	Tue Dec 08 13:52:14 2009 -0500
+++ b/src/plugins/quota/quota-private.h	Tue Dec 08 17:52:10 2009 -0500
@@ -145,7 +145,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 b348632b11e2 -r a9b469e1c8de src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Tue Dec 08 13:52:14 2009 -0500
+++ b/src/plugins/quota/quota.c	Tue Dec 08 17:52:10 2009 -0500
@@ -262,19 +262,17 @@ quota_rule_parse_percentage(struct quota
 
 static void
 quota_rule_recalculate_relative_rules(struct quota_rule *rule,
-				      const struct quota_rule *default_rule)
-{
-	if (rule->bytes_percent > 0) {
-		rule->bytes_limit = default_rule->bytes_limit *
-			rule->bytes_percent / 100;
-	}
-	if (rule->count_percent > 0) {
-		rule->count_limit = default_rule->count_limit *
-			rule->count_percent / 100;
-	}
-}
-
-void quota_root_recalculate_relative_rules(struct quota_root_settings *root_set)
+				      int64_t bytes_limit, int64_t count_limit)
+{
+	if (rule->bytes_percent > 0)
+		rule->bytes_limit = bytes_limit * rule->bytes_percent / 100;
+	if (rule->count_percent > 0)
+		rule->count_limit = count_limit * rule->count_percent / 100;
+}
+
+void quota_root_recalculate_relative_rules(struct quota_root_settings *root_set,
+					   int64_t bytes_limit,
+					   int64_t count_limit)
 {
 	struct quota_rule *rules;
 	struct quota_warning_rule *warning_rules;
@@ -282,14 +280,14 @@ void quota_root_recalculate_relative_rul
 
 	rules = array_get_modifiable(&root_set->rules, &count);
 	for (i = 0; i < count; i++) {
-		quota_rule_recalculate_relative_rules(&rules[i],
-						      &root_set->default_rule);
+		quota_rule_recalculate_relative_rules(&rules[i], bytes_limit,
+						      count_limit);
 	}
 
 	warning_rules = array_get_modifiable(&root_set->warning_rules, &count);
 	for (i = 0; i < count; i++) {
 		quota_rule_recalculate_relative_rules(&warning_rules[i].rule,
-						      &root_set->default_rule);
+						      bytes_limit, count_limit);
 	}
 }
 
@@ -419,7 +417,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_info("Quota rule: root=%s mailbox=%s "
 		       "bytes=%lld%s messages=%lld%s", root_set->name,
@@ -580,7 +580,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_info("Quota warning: bytes=%llu%s "
 		       "messages=%llu%s command=%s",


More information about the dovecot-cvs mailing list