changeset 12453:3a93121f652a

quota: If user has unlimited quota, ignore any specific quota rules.
author Timo Sirainen <tss@iki.fi>
date Mon, 22 Nov 2010 18:35:07 +0000
parents b724ef3bdc0a
children 66a523135836
files src/plugins/quota/quota.c
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/quota/quota.c	Mon Nov 22 18:21:25 2010 +0000
+++ b/src/plugins/quota/quota.c	Mon Nov 22 18:35:07 2010 +0000
@@ -588,7 +588,7 @@
 {
 	struct quota_rule *rule;
 	int64_t bytes_limit, count_limit;
-	bool found;
+	bool enabled;
 
 	if (!root->set->force_default_rule) {
 		if (root->backend.v.init_limits != NULL) {
@@ -600,11 +600,11 @@
 	bytes_limit = root->bytes_limit;
 	count_limit = root->count_limit;
 
-	/* if default rule limits are 0, this rule applies only to specific
-	   mailboxes */
-	found = bytes_limit != 0 || count_limit != 0;
+	/* if default rule limits are 0, user has unlimited quota.
+	   ignore any specific quota rules */
+	enabled = bytes_limit != 0 || count_limit != 0;
 
-	rule = quota_root_rule_find(root->set, mailbox_name);
+	rule = enabled ? quota_root_rule_find(root->set, mailbox_name) : NULL;
 	if (rule != NULL) {
 		if (!rule->ignore) {
 			bytes_limit += rule->bytes_limit;
@@ -613,12 +613,11 @@
 			bytes_limit = 0;
 			count_limit = 0;
 		}
-		found = TRUE;
 	}
 
 	*bytes_limit_r = bytes_limit <= 0 ? 0 : bytes_limit;
 	*count_limit_r = count_limit <= 0 ? 0 : count_limit;
-	return found ? 1 : 0;
+	return enabled ? 1 : 0;
 }
 
 void quota_add_user_namespace(struct quota *quota, struct mail_namespace *ns)