dovecot-1.2: dict quota: When updating quota don't look up the c...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jan 19 22:31:02 EET 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/d326adcfd518
changeset: 8658:d326adcfd518
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jan 19 15:30:58 2009 -0500
description:
dict quota: When updating quota don't look up the current byte/msg limit if there's no limit for it.

diffstat:

1 file changed, 32 insertions(+), 24 deletions(-)
src/plugins/quota/quota.c |   56 +++++++++++++++++++++++++--------------------

diffs (73 lines):

diff -r e579406fdab6 -r d326adcfd518 src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Mon Jan 19 12:08:51 2009 -0500
+++ b/src/plugins/quota/quota.c	Mon Jan 19 15:30:58 2009 -0500
@@ -741,7 +741,7 @@ static int quota_transaction_set_limits(
 	struct quota_root *const *roots;
 	const char *mailbox_name;
 	unsigned int i, count;
-	uint64_t current, limit, left;
+	uint64_t bytes_limit, count_limit, current, limit, left;
 	int ret;
 
 	ctx->limits_set = TRUE;
@@ -753,29 +753,37 @@ static int quota_transaction_set_limits(
 		if (!quota_root_is_visible(roots[i], ctx->box, TRUE))
 			continue;
 
-		ret = quota_get_resource(roots[i], mailbox_name,
-					 QUOTA_NAME_STORAGE_BYTES,
-					 &current, &limit);
-		if (ret > 0) {
-			current += ctx->bytes_used;
-			left = limit < current ? 0 : limit - current;
-			if (ctx->bytes_left > left)
-				ctx->bytes_left = left;
-		} else if (ret < 0) {
-			ctx->failed = TRUE;
-			return -1;
-		}
-		
-		ret = quota_get_resource(roots[i], mailbox_name,
-					 QUOTA_NAME_MESSAGES, &current, &limit);
-		if (ret > 0) {
-			current += ctx->count_used;
-			left = limit < current ? 0 : limit - current;
-			if (ctx->count_left > left)
-				ctx->count_left = left;
-		} else if (ret < 0) {
-			ctx->failed = TRUE;
-			return -1;
+		(void)quota_root_get_rule_limits(roots[i], mailbox_name,
+						 &bytes_limit, &count_limit);
+
+		if (bytes_limit > 0) {
+			ret = quota_get_resource(roots[i], mailbox_name,
+						 QUOTA_NAME_STORAGE_BYTES,
+						 &current, &limit);
+			if (ret > 0) {
+				current += ctx->bytes_used;
+				left = limit < current ? 0 : limit - current;
+				if (ctx->bytes_left > left)
+					ctx->bytes_left = left;
+			} else if (ret < 0) {
+				ctx->failed = TRUE;
+				return -1;
+			}
+		}
+
+		if (count_limit > 0) {
+			ret = quota_get_resource(roots[i], mailbox_name,
+						 QUOTA_NAME_MESSAGES,
+						 &current, &limit);
+			if (ret > 0) {
+				current += ctx->count_used;
+				left = limit < current ? 0 : limit - current;
+				if (ctx->count_left > left)
+					ctx->count_left = left;
+			} else if (ret < 0) {
+				ctx->failed = TRUE;
+				return -1;
+			}
 		}
 	}
 	return 0;


More information about the dovecot-cvs mailing list